P/Invoke calls with pointers

borjolujo

New member
Joined
Aug 25, 2009
Messages
1
Programming Experience
1-3
I´m noob with C++, i need the Visual Basic .NET (Compact Framework 1.1) P/Invoke calls of a Garmin

Mobile XT API functions (Garmin Mobile SDKs - Garmin Developer). I transforms others

calls, but these with pointers and handles is too hard to me. Here is the info:


-- Function prototypes --
QueAPIExport QueErrT16 QueCreatePoint( const QuePointType* point, QuePointHandle* handle );
QueAPIExport QueErrT16 QueRouteToPoint( QuePointHandle point );

-- QueAPIExport --
#define QueAPIExport __declspec(dllimport)

-- QueErrT16 --
typedef uint16 QueErrT16; enum { ... }

-- QuePointType --
typedef struct { ... } QuePointType;

-- QuePointHandle --
typedef uint32 QuePointHandle;


The best try (i think) for me was (sending a IntPtr.Zero to first function, an error for sure):

<DllImport("QueAPI.dll")> _
Public Shared Function QueCreatePoint(ByRef point As QuePointType, ByRef handle As IntPtr) As

QueErrT16
End Function

<DllImport("QueAPI.dll")> _
Public Shared Function QueRouteToPoint(ByVal point As IntPtr) As QueErrT16
End Function



If it can help, i will write a part of code (C++) of a person that makes a API Wrapper

(Christian Helle's Blog: Integrating with Garmin Mobile XT). I want make

the same but in VB.Net:

QuePointType point;
QuePositionDataType position;

memset(&position, 0, sizeof(QuePositionDataType));
position.lat = DecimalDegreesToSemicircles(latitude);
position.lon = DecimalDegreesToSemicircles(longitude);

memset(&point, 0, sizeof(QuePointType));
point.posn = position;

QuePointHandle hPoint;
memset(&hPoint, 0, sizeof(QuePointHandle));

err = QueCreatePoint(&point, &hPoint);
if (err == queErrNone && hPoint != queInvalidPointHandle) {
err = QueRouteToPoint(hPoint);
}


I said i´m noob in C++, so i will tell you (maybe unneccessary) that nemset function is originally

from MEMORY.H and is prototype::

void * __cdecl memset(void *, int, size_t);



Thanks :)
 
Back
Top