Import eVC dll to VB.net CF

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi,

I am new to work with different languages, just wonder if anyone can help to
import the dll which was written from eVC++.

GPS.dll

BOOL GPSInit( HANDLE AppHandle , USHORT MessageId , GPS_PARMS );

BOOL GPSReadData( GPS_DATA);

Thanks.

LK
 
BOOL = int
HANDLE = IntPtr
USHORT = UInt16
GPS_PARMS = not enough info provided
GPS_DATA = not enough info providied

-Chris
 
Hi, Chris,

Here is the details.
Ini:

AppHandle [in] Application Window Handle
MessageId [in] Window notification message id used to notify the application
of a GPS Event.
Gps_Parms [in] Pointer to the GPS_PARM data structure.

typedef struct { USHORT Type; BYTE ComPortID; USHORT NoFixInterval; USHORT }
GPS_PARM;


Read:
GpsData [out] Pointer to a GPS_DATA data structure.

typedef struct { BYTE Status;
int TimeOfDay;
BOOL valid_time;
USHORT day;
USHORT month;
USHORT year;
USHORT hour;
USHORT min;
USHORT sec;
double Latitude;
double Longitude;
double Altitude;
double Heading;
double Speed;
char DllVersion[GPS_VERSION_LENGTH + 1];
char pVersion[GPS_VERSION_LENGTH + 1];
char pStatusBuf[GPS_STATUS_LENGTH+1];
char pLatBuf[LATITUDE_LENGTH+1];
char pLonBuf[LONGITUDE_LENGTH+1];
char pAltBuf[ALTITUDE_LENGTH+1];
char pHeadBuf[GPS_HEADING_LENGTH+1];
USHORT ResetCount;
USHORT FailureCount;
USHORT ResetReason; } GPS_DATA;

How should I declare these functions?

Regards,

LK
 
For GPS_PARM, you'll have to declare a class with the indicated fields and
arrange to pass that to the call, or perhaps have a ToByteArray() method in
the class that returns an array of bytes in the right memory layout for the
structure. Declare the call appropriately to match your strategy.
OpenNETCF, www.opennetcf.org, does this all over the place.

GPS_DATA is going to want to use the byte array method and there are a
number of memory layout things that you're going to have to handle (the
first BYTE field, Status, is actually going to take up 4 bytes in memory
because of alignment restrictions on the int type, TimeOfDay, which follows
it).

I'd consult the vendor of this DLL and see if they can't do a better job of
providing a managed interface. If the vendor is you, you'll need to
carefully document the offsets of each field from the start of the structure
and make sure that you match that when you pass your byte array to the call.

Paul T.

John said:
Hi, Chris,

Here is the details.
Ini:

AppHandle [in] Application Window Handle
MessageId [in] Window notification message id used to notify the
application of a GPS Event.
Gps_Parms [in] Pointer to the GPS_PARM data structure.

typedef struct { USHORT Type; BYTE ComPortID; USHORT NoFixInterval;
USHORT } GPS_PARM;


Read:
GpsData [out] Pointer to a GPS_DATA data structure.

typedef struct { BYTE Status;
int TimeOfDay;
BOOL valid_time;
USHORT day;
USHORT month;
USHORT year;
USHORT hour;
USHORT min;
USHORT sec;
double Latitude;
double Longitude;
double Altitude;
double Heading;
double Speed;
char DllVersion[GPS_VERSION_LENGTH + 1];
char pVersion[GPS_VERSION_LENGTH + 1];
char pStatusBuf[GPS_STATUS_LENGTH+1];
char pLatBuf[LATITUDE_LENGTH+1];
char pLonBuf[LONGITUDE_LENGTH+1];
char pAltBuf[ALTITUDE_LENGTH+1];
char pHeadBuf[GPS_HEADING_LENGTH+1];
USHORT ResetCount;
USHORT FailureCount;
USHORT ResetReason; } GPS_DATA;

How should I declare these functions?

Regards,

LK


BOOL = int
HANDLE = IntPtr
USHORT = UInt16
GPS_PARMS = not enough info provided
GPS_DATA = not enough info providied

-Chris
 
Back
Top