Ascend4nt Posted March 22, 2009 Posted March 22, 2009 Okay, don't mean to be greedy with questions, but this question has been sitting in the Help forum for a couple of weeks, so I'm reposting it here: It was pointed out to me that DLLCall's will automatically set up a return buffer for datatypes marked as "str" or "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 "str" or "wstr", AutoIT will set up a default buffer (and 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 automatically allocated 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 My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
ProgAndy Posted March 22, 2009 Posted March 22, 2009 I found a function where wstr doesn't work (ReadConsoleW). I always got some additional characters from the console window. So i created a wchar-Buffer and now it works. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Valik Posted March 22, 2009 Posted March 22, 2009 IIRC you pass "wstr*", not "wstr". But it is not necessary to allocate your own buffer.
Ascend4nt Posted March 23, 2009 Author Posted March 23, 2009 Through testing, "wstr*" doesn't work, but "wstr" does. Couldn't tell you why. I wonder why its not working for ProgAndy.. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now