Announcement

Collapse
No announcement yet.

Calling a C function correctly...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling a C function correctly...

    Hello,

    The following C call sets a pointer to a null terminated string providing
    the version number of the API library:

    CWidget_getLibraryVersion(char **buffer)

    I've recast it as follows:

    DECLARE FUNCTION CWidget_getLibraryVersion LIB "phidget21.dll" ALIAS "CWidget_getLibraryVersion" (BYVAL libVer AS LONG)

    and make the call like this:

    DIM char AS ASIIZ*25
    CWidget_getLibraryVersion(deviceHandle, VARPTR(char))

    When I check 'char' it contains something, but now what I'd expect. Therefore, I
    think I'm doing something wrong - perhaps not realizing what ** means? Any help
    would be greatly appreciated.

    -CMR



    ------------------

  • #2
    The function declaration has one parameter and you call it passing two?

    Anyway, ** means double indirection (a pointer to an pointer).
    Change BYVAL libVer AS LONG to BYREF libVer AS DWORD and use:
    Code:
    DIM pchar AS ASCIIZ PTR
    CWidget_getLibraryVersion(pchar)
    MSGBOX @pchar

    ------------------
    Website: http://com.it-berater.org
    SED Editor, TypeLib Browser, COM Wrappers.
    Forum: http://www.forum.it-berater.org
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Yes, you're right, that first param should not be there - my mistake.
      However, I just tried your suggestion and it solved my problem - thanks again!


      Originally posted by José Roca:
      The function declaration has one parameter and you call it passing two?

      Anyway, ** means double indirection (a pointer to an pointer).
      Change BYVAL libVer AS LONG to BYREF libVer AS DWORD and use:
      Code:
      DIM pchar AS ASCIIZ PTR
      CWidget_getLibraryVersion(pchar)
      MSGBOX @pchar



      ------------------

      Comment


      • #4
        >** means double indirection

        Darn. I thought <U>two</U> stars meant <U>really</U> important!

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment

        Working...
        X