Ascend4nt Posted July 11, 2009 Share Posted July 11, 2009 I was looking at the function PathFindOnPath, and while it's nice that it looks at the paths in the %PATH% environment variable, I wanted to be able to supply additional ones in the second parameter. Unfortunately, what it says for the 2nd parameter is a 'null-terminated array of directories' (or NULL).So from looking around the web to get an idea of how 'array' is setup in memory, the conclusion I came to was that it must be a list of pointers to strings. So I tried this code out, and its not finding the file I want (and I know it to exist in the first directory I set):$stFolderPaths=DllStructCreate("wstr[256];wstr[256];wstr[256]") DllStructSetData($stFolderPaths,1,@DesktopDir&'\t2') DllStructSetData($stFolderPaths,2,@ScriptDir) DllStructSetData($stFolderPaths,3,@WorkingDir) $stPathPtrs=DllStructCreate("ptr;ptr;ptr;ptr") DllStructSetData($stPathPtrs,1,DllStructGetPtr($stFolderPaths)) DllStructSetData($stPathPtrs,2,DllStructGetPtr($stFolderPaths,2)) DllStructSetData($stPathPtrs,3,DllStructGetPtr($stFolderPaths,3)) DllStructSetData($stPathPtrs,4,Ptr(0)) Local $aRet=DllCall("shlwapi.dll","int","PathFindOnPathW","wstr","notepad.txt","ptr",DllStructGetPtr($stPathPtrs)) If Not @error Then ConsoleWrite("Return values of PathFindonPath call: BOOL:"&$aRet[0]&", String:"&$aRet[1]&@CRLF)Of course, the above doesn't work. I'm probably missing something obvious, but I was sure I was following the logic as it appeared on a few sites.Any help is appreciated.. thanks 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) Link to comment Share on other sites More sharing options...
monoceres Posted July 11, 2009 Share Posted July 11, 2009 Hrm, does the string "wchar" say you anything? Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Ascend4nt Posted July 11, 2009 Author Share Posted July 11, 2009 (edited) Hrm, does the string "wchar" say you anything? Holy crap, what a stupid move! haha, thank you for pointing it out. It HAD to be obvious didn't it. I do that occasionally (mix up my DLLCall variable descriptors with my DLLStruct ones). Thanks so much man. By the way, for those that don't get it, this one line change is what fixes it: $stFolderPaths=DllStructCreate("wchar[256];wchar[256];wchar[256]") *edit: Just a note: 256 was kinda random, I forgot that MAX_PATH is 260, so that could have been used instead, or the actual length of the string that its going to contain (more memory efficient). Edited July 11, 2009 by 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) Link to comment Share on other sites More sharing options...
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