Announcement

Collapse
No announcement yet.

Help with my first DLL :)

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

  • Neil Hosgood
    replied
    Thanx Lance, thats the answer I needed.
    you're a god.

    PS. on my journey through the PB6 help file on the topic of
    creating a DLL I was disturbed to find it telling me to
    start up the PB5 editor. (hmmm if I bought a new car would I
    expect it to come with a manual for last years model?)
    Just my little bleat for the day.
    have Fun.
    N.

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

    Leave a comment:


  • Lance Edmonds
    replied
    If you are passing the ASCIIZ string (byref) from Delphi, then it should be passing a pointer to the ASCIIZ string data, hence you would construct the function prototype something like this:
    Code:
    FUNCTION DllFunc ALIAS "DllFunc" (mystr AS ASCIIZ) EXPORT AS LONG
    I have left off the "length" qualifier which is acceptable, provided you do not attempt to access memory beyond the length of the passed string. With the length qualifier, PowerBASIC will protect you from this to some degree, but only if the length of the passed ASCIIZ string is equal to or greater than the length specified in the PB code Function prototype. (Clear as mud? )

    Also, you need to include the keyword EXPORT, or the function will not be "visible" to the Delphi app.

    Finally, I added an ALIAS clause to specify the exported Function name specifically... exported Sub/Function names are case-sensitive in 32-bit Windows.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Neil Hosgood
    started a topic Help with my first DLL :)

    Help with my first DLL :)

    Hi all.
    After telling my employer that I refuse to learn Delphi I
    now have to write a DLL in PB that he can use with Delphi.
    Problem is that haven written many EXE's I have never written
    a DLL, let alone called a PB DLL from Delphi.
    Question is... most of the functions in my DLL require a string
    to be passed, an asciiZ to be extact, so in my DLL do I set up
    the parameters as Function ... (string1 as asciiZ * 255) as Long
    OR Function ... (String1 as Long) as Long ?
    You will have to excuse my ignorance, I am used to just throwing
    dynamic strings around my own EXE in windows



    ------------------
Working...
X