Jump to content

help with dllcall


devilyn
 Share

Recommended Posts

extern "C" __declspec(dllexport) char** test()
{
static char* myArray[3] = {"A1", "BB2", "CC3"};
return myArray;
}

im trying to get the array from the function above using dllcall

this is what i got so far

Global $sum = DllCall('DllExport.dll', 'str', 'test')
If @error then MsgBox(0,"e",@error)
_ArrayDisplay($sum)

dll is attached.

thx

DllExport.7z

Edited by devilyn
Link to comment
Share on other sites

Problems:

  • Return type is not 'str'
  • You are using the cdecl calling convention, so your return type would be 'ptr:cdecl'
  • AutoIt can't use your dll as you've attached anyway. I suspect that means its not a native dll.
  • I suspect when you close the dll you'll lose the static variable.
Unfortunately I don't have access to a compiler to rewrite your dll at the moment.

You shouldn't allocate memory from within the dll function anyway, its standard practice that the caller should allocate and free the memory. Trying to work with an array of C strings is going to be tricky anyway, perhaps a callback function for each item would be a better approach.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...