Page 1 of 1
Purebasic dll return string as pchar to Delphi application
Posted: Mon Dec 03, 2007 8:12 pm
by mrniceguy1971
How can I return a string in a Purebasic dll as a pchar value to Delphi?
Any suggestions are welcome.
Posted: Tue Dec 04, 2007 4:03 am
by PurePWNRER
have your dll allocate the string data to a memory address, then pass this address to your delphi application. if delphi reads normal ascii strings then it'll work. if not, drop delphi, it's crap.
Posted: Tue Dec 04, 2007 5:40 am
by Mistrel
From what I read online pchar is basically a pointer to a bit of memory allocated for string use. Try adding an @ in front of the variable when you pass it to your procedure and see if it works.
Posted: Tue Dec 04, 2007 10:20 am
by mrniceguy1971
Thanks I will try it.
Posted: Tue Dec 04, 2007 1:12 pm
by srod
If your dll declares a string as geing global and returns that, then I see no reason why this should not work.
Posted: Tue Dec 04, 2007 11:25 pm
by Mistrel
srod has a good point. Make sure that your string isn't a local variable that pops after your function passes the pointer.