P/Invoke calls with pointers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • borjolujo
    New Member
    • Aug 2009
    • 3

    #1

    P/Invoke calls with pointers

    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 (http://developer.garmi n.com/mobile/mobile-sdk/). 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(dlli mport)

    -- 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("Que API.dll")> _
    Public Shared Function QueCreatePoint( ByRef point As QuePointType, ByRef handle As IntPtr) As QueErrT16
    End Function

    <DllImport("Que API.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 (http://christian-helle.blogspot. com/2008/02/integrating-with-garmin-mobile-xt.html). I want make

    the same but in VB.Net:

    QuePointType point;
    QuePositionData Type position;

    memset(&positio n, 0, sizeof(QuePosit ionDataType));
    position.lat = DecimalDegreesT oSemicircles(la titude);
    position.lon = DecimalDegreesT oSemicircles(lo ngitude);

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

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

    err = QueCreatePoint( &point, &hPoint);
    if (err == queErrNone && hPoint != queInvalidPoint Handle) {
    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 :)
Working...