Purebasic dll return string as pchar to Delphi application

Just starting out? Need help? Post your questions and find answers here.
mrniceguy1971
User
User
Posts: 56
Joined: Tue May 16, 2006 3:52 pm

Purebasic dll return string as pchar to Delphi application

Post by mrniceguy1971 »

How can I return a string in a Purebasic dll as a pchar value to Delphi?

Any suggestions are welcome.
PurePWNRER
User
User
Posts: 45
Joined: Mon Mar 27, 2006 5:44 am

Post 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.
:/ My kingdom for a snippet!
I might bash, But I provide.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post 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.

Code: Select all

procedure.. ( param1, @string.s )
mrniceguy1971
User
User
Posts: 56
Joined: Tue May 16, 2006 3:52 pm

Post by mrniceguy1971 »

Thanks I will try it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

If your dll declares a string as geing global and returns that, then I see no reason why this should not work.
I may look like a mule, but I'm not a complete ass.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post 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.
Post Reply