Jump to content

DllCall pointer return type revisited


Go to solution Solved by funkey,

Recommended Posts

Sorry I'm asking this again.  Don't want to bug you good people but I still can't find a way to solve this problem.

I am calling a function in a DLL using DllCall in AutoIT.  The function's return type is a pointer to an array of bytes.  I've tried everything I can think of to try to get the actual array but nothing works.  I don't have the source code for the DLL, only the header.

I am using OpenDll and getting @error=0

The function has two parameters and they are being set as expected by the function.

How can I get to the data that the DLL is returning a pointer to?

Link to comment
Share on other sites

  • Solution

Some example code how to do it in general:

Global $aRet = DllCall("example.dll", "ptr", ...)


Global $tResult = DllStructCreate("byte array[20]", $aRet[0])

For $i = 1 To DllStructGetSize($tResult)
    ConsoleWrite(DllStructGetData($tResult, 1, $i) & @LF)
Next

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

It's not possible to be specific without seeing the code, but this reminds me of a similar issue from the past, which was fixed by using the correct calling method, i.e. "cdecl".

;o) Cor

nothing is foolproof to the sufficiently talented fool..

Link to comment
Share on other sites

New Dad,

Thank you so much for that code snippet.  It works perfectly!!!  It saved me from having to rewrite my app in C, so I owe you big-time.  If you're ever in the San Diego area look me up and I'll buy the beers.

And congrats on being a new dad!

Doug

Link to comment
Share on other sites

New Dad,

Thank you so much for that code snippet.  It works perfectly!!!  It saved me from having to rewrite my app in C, so I owe you big-time.  If you're ever in the San Diego area look me up and I'll buy the beers.

And congrats on being a new dad!

Doug

You are welcome. I'm glad I could help you. I was in San Diego in 2012, but I don't think I will ever be there again, because world is just to big. ;)

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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