Announcement

Collapse
No announcement yet.

Need help calling a DLL with PTR parm

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

  • Need help calling a DLL with PTR parm

    I need to call a DLL with a prototype which looks like this:

    'BOOL DLLENTRY SomeDLL(GLOBALHANDLE FAR *SomeList)
    DECLARE FUNCTION SomeDLL LIB "SOME.DLL" (BYVAL SomeList AS DWORD PTR) AS LONG

    The dword points to a string array. How do I define this, and how do I define an array to use this pointer?

    DIM SomeArray(10) AS STRING ' The list
    DIM SomeList as DWORD PTR ' Doesn't this point to a DWORD?
    SomeList = VARPTR(SomeArray()) ' To get the string segment?



    ------------------
    Thanks,

    John Kovacich
    Thanks,

    John Kovacich
    Ivory Tower Software

  • #2
    By the looks of the C function above your DECLARE, assuming that's the
    same function, SomeList is a pointer to a GLOBALHANDLE (which
    is a HANDLE, which is a DWORD). Literally, the translation to
    BYVAL SomeList AS DWORD PTR is correct. However, it is useful
    to remember that C has no way of passing anything BYREF except by
    using pointers. In this case, what you want is more probably:
    Code:
    DECLARE FUNCTION SomeDLL ALIAS "SomeDLL" LIB "SOME.DLL" (BYREF SomeList AS DWORD) AS LONG
    Now, SomeList here is really a GLOBALHANDLE, which is very much
    not a string array. Of course, in C or in PowerBASIC, it is common enough
    to define a parameter as one thing for convenience, and then override it
    at some other point. It would be fairly odd to coerce a GLOBALHANDLE into
    a string array, though, I think. It seems like a step or two must be
    missing here. Can you provide more detail?

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment

    Working...
    X