Jump to content

AutoIT developers question - DLL return of wstr


Recommended Posts

For AutoIT developers, I have a quick question:

It was pointed out to me that DLLCall's will automatically set up a return buffer for datatypes marked as "wstr". The way I've been coding it is to use DLLStructCreate("wstr[#]") and send it as a pointer to ensure that I have a buffer large enough to receive the data.

However, I have been told that instead, I can pretty much take it as a given that if I simply put "wstr" AutoIT will set up a default buffer (it was mentioned that this buffer will be 65536 chars/wchars). I know the help file describes a 'maximum' of the same, but I thought this was intended for passing data *to* a DLL call though?

So, I'd just like to know if I can rely on this automatic return-buffer setup or not.

For an example (cut from '_WinAPI_ProcesGetFileName'):

$stImageFilename=DllStructCreate("wchar[32767]")
$aRet=DllCall("Psapi.dll","dword","GetProcessImageFileNameW","ptr",$hProcess[0],"ptr", _
        DllStructGetPtr($stImageFilename),"ulong",32767)

Would this be able to be replaced with:

$aRet=DllCall("Psapi.dll","dword","GetProcessImageFileNameW","ptr",$hProcess[0],"wstr","","ulong",32767)

Clarification is much appreciated, thanks,

Ascend4nt

*edit - added example

Edited by ascendant
Link to comment
Share on other sites

well, I hardly ever do this, but *BUMP* :unsure:

Not sure if I should have posted this elsewhere :P

Link to comment
Share on other sites

Well, I mean really *any* DLL call that expects a Return buffer set up to collect data.

For example (cut from '_WinAPI_ProcesGetFileName'):

$stImageFilename=DllStructCreate("wchar[32767]")
$aRet=DllCall("Psapi.dll","dword","GetProcessImageFileNameW","ptr",$hProcess[0],"ptr", _
        DllStructGetPtr($stImageFilename),"ulong",32767)
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...