06-06-2019 10:24 AM
Hello everybody,
I am trying to call a function in DLL created with Delphi. The function takes File name (type Pchar) as the parameter and returns the file handle (signed integer 32).
I wrote a very simple VI consisting of a String constant linked to a Call Library Function Node. In the Call Library Function Node I used stdcall Calling Convention and String - Pascal String Pointer as arg1. When I run the vi, the dll returns error code as it is junk characters instead of the file name (show in the attached image) passed to the function. I am suspecting this has to do with how Labview string is passed to Pchar data type
I have tried all combinations of Calling Convention and argument type in the Call Library Function Node but none seemed to work.
Can any body tell me how to pass labview string to Pchar in delphi?
Thank you very much!
Solved! Go to Solution.
06-06-2019 10:55 AM
I might be wrong thought delphi strings were typically null terminated like C strings, not prepended with length like pascal strings.
I would wire the string in as C string pointer.
0xDEAD
06-06-2019 11:22 AM
I tried that and still the same result.
06-06-2019 12:02 PM - edited 06-06-2019 12:03 PM
Did you try appending a null terminator to the string? I haven't any delphi experience, not sure how fussy it is.
06-06-2019 12:27 PM
I was bored, so did a bit of googling. It seems that in certain Delphi versions the default Char is a 16 bit (unicode rather than ANSI string).
Looking at the garbage you got back, this might be the issue.
06-06-2019 01:36 PM
Thank you. I was able to finally get it working by using the STR_ASCII-Unicode.vi lcoated in "vi.lib\registry\registry.llb" to convert the string to unicode and passing it to the c String
06-06-2019 02:23 PM
No problem. I got to learn something new.
0xDEAD