Calling a DLL Function

Just starting out? Need help? Post your questions and find answers here.
ac667788
User
User
Posts: 10
Joined: Sun May 13, 2007 6:50 am

Calling a DLL Function

Post by ac667788 »

How would you guys call this DLL Function

void hesl::version(int *major, int *minor, char **verstr);

I tried the following and the values at *major and *minor are okay but I don't know how to handle char **verstr

Code: Select all

  *major = @major.i
  *minor = @minor.i
  version.s = ""
  *version = @version.s
  CallFunctionFast(*F, *major, *minor, *version)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

PeekS(*version) would be my guess.
BERESHEIT
ac667788
User
User
Posts: 10
Joined: Sun May 13, 2007 6:50 am

Post by ac667788 »

PeekS(*version) gives me the same garbage as before
User avatar
Deeem2031
Enthusiast
Enthusiast
Posts: 216
Joined: Sat Sep 20, 2003 3:57 pm
Location: Germany
Contact:

Post by Deeem2031 »

Try @*version as the last parameter.
irc://irc.freenode.org/#purebasic
ac667788
User
User
Posts: 10
Joined: Sun May 13, 2007 6:50 am

Post by ac667788 »

Changes things a bit but the data at

version
*version
@*version

is still garbage
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

is the function in the DLL CDECL or STDCALL , maybe try CallCFunctionFast ?

[edit]
try this

Code: Select all

version.s
*ptr
CallFunctionFast(*F, *major, *minor, *ptr) 
version=PeekS(*ptr)
[/edit]
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I think you will also need to allocate a buffer first because it looks like the function will write a string directly into this buffer.

Code: Select all

version.s = Space(1024) 
CallFunctionFast(*F, @major, @minor, @version) 
Perhaps using CallCFunctionFast() instead as Jack suggested.
I may look like a mule, but I'm not a complete ass.
Post Reply