Sign in to follow this  
Followers 0
laosoi

C++ return an array, how to get it using DllCall?

5 posts in this topic

#1 ·  Posted (edited)

The first C++ code:

extern "C" __declspec(dllexport) int * BioBus(void) {

int*getlo=new int[3];

getlo[0]=1000;

getlo[1]=2000;

getlo[2]=3000;

return getlo;

}

Please teach me, how to get "getlo"?

The second C++ code:

extern "C" __declspec(dllexport) const char * BioBus(void) {

const char * yo="Hello world!";

return yo;

}

Autoit code: DLLCall($dll,"str","BioBus") run OK! But:

extern "C" __declspec(dllexport) const char * BioBus(void) {

string message="Hello world!";

const char * yo=message.c_str();

return yo;

}

When i use DLLCall($dll,"str","BioBus") it return wrong string. Please tell me how to solve these problem! Thank you!

Edited by laosoi

Share this post


Link to post
Share on other sites



I'm no dll expert but maybe this helps :

$dll_handle = DLLCall($dll,"str","BioBus")
For $i = 1 To $dll[0]
      MsgBox(0, "", $dll[$i])
Next

or

$dll_handle = DLLCall($dll,"str","BioBus")
For $i = 1 To Ubound($dll_handle) - 1
      MsgBox(0, "", $dll[$i])
Next

Share this post


Link to post
Share on other sites

mrbond007, as your reply:

$dll_handle = DLLCall($dll,"str","BioBus")

For $i = 1 To Ubound($dll_handle) - 1

MsgBox(0, "", $dll_handle[$i])

Next

But it returned an empty value! Anyway, thank you!

Any ideas?

Share this post


Link to post
Share on other sites

mrbond007, as your reply:

$dll_handle = DLLCall($dll,"str","BioBus")

For $i = 1 To Ubound($dll_handle) - 1

MsgBox(0, "", $dll_handle[$i])

Next

But it returned an empty value! Anyway, thank you!

Any ideas?

maybe there is an error

$dll_handle = DLLCall($dll,"str","BioBus")
Msgbox(0, "", @error)

if the msgbox returns a different value than 0 than check the help file. Sorry that i can't help you more than this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0