Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: DLL String Pointer Question

  1. #11

    Default Re: DLL String Pointer Question

    Hi Markus,

    > I've forgotten one thing:
    >
    > > a *CSTRING requires eight bytes.
    >
    > What ist the format of *CSTRING? 4 bytes pointer + 4 bytes length?

    It's some kind of "hidden" pointer to an appropriate amount of memory. It
    pushes a hidden argument on the stack, which is a pointer to a temporary
    buffer (located on the stack). The called function itself then copies the
    return value to this buffer.

    Friedrich

  2. #12

    Default Re: DLL String Pointer Question

    Is this clarion specific?

    Or can you give me a "real world" example, when I should use *CSTRING?

    Markus

  3. #13

    Default Re: DLL String Pointer Question

    Hi Markus,

    > Is this clarion specific?
    >
    > Or can you give me a "real world" example, when I should use *CSTRING?

    If you make use of Windows APIs or DLLs written in Visual Studio C/C++ then
    you would not use the *CSTRING type. You would use *STRING in this case.

    To be honest, I don't know if this is Clarion specific. But we need this
    type if we call a Clarion DLL.

    Friedrich

  4. #14

    Default Re: DLL String Pointer Question

    Thank you.

    Markus

  5. #15

    Default Re: DLL String Pointer Question

    Hi Friedrich,

    here are the important sentences of our conversation. It would be nice,
    if you could add this to the documentation:

    String Encoding
    The "Call Dll" script function makes use of the ANSI string encoding.

    Result Type
    The internal return types in the underlying Call Dll methoda are an
    union of standard types, ranging from a four-byte INT (generic four-byte
    type) to an eight-byte DOUBLE. %_SB_RETURN% itself is "typeless". SB
    script variables are always represented as String and SB do the
    conversion on the fly, if it is needed for arithmetics or call dll and
    so on.

    *STRING and *CSTRING
    The difference between *CSTRING and *STRING is that the byte width of
    the individual function arguments is different (64 bit for *CSTRING and
    32 bit for *STRING). In the Call DLL method, it always allocates 10,240
    bytes. All the parameters are pushed directly onto the stack. If the
    called function (e.g. GetUserName) returns then it copies the retrieved
    return value via lstrcpy() to the "final" variable location (e.g.
    %STRINGBUFFER%). This variable is dynamically allocated (using
    lstrlen). Everything you have after the null terminating character is
    "ignored" in this final step. We adjust the stack and read the return
    value(s). If the return value isn't passed through registers, memory
    copy is performed instead.

    What ist the format of *CSTRING?
    It's some kind of "hidden" pointer to an appropriate amount of memory. It
    pushes a hidden argument on the stack, which is a pointer to a temporary
    buffer (located on the stack). The called function itself then copies the
    return value to this buffer.

    When should I use *CSTRING and when *STRING?
    If you make use of Windows APIs or DLLs written in Visual Studio C/C++
    then you would use the *STRING type. If you call a Clarion DLL, use
    *CSTRING.


    Markus

  6. #16

    Default Re: DLL String Pointer Question

    Hi Friedrich,

    this seems not to be added to the coumentation in 7.2.3062

    Markus

  7. #17

    Default Re: DLL String Pointer Question

    Hi Markus,

    >
    > this seems not to be added to the coumentation in 7.2.3062
    >

    I don't know if there were plans to add this to the documentation. But I'll
    check this.

    Thanks,
    Friedrich

  8. #18

    Default Re: DLL String Pointer Question

    Added as a FAQ topic to the "Call DLL Function" description now.

    Thanks,
    Friedrich

  9. #19

    Default Re: DLL String Pointer Question

    Thank you.

    Markus Zander

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •