FreeFry Posted June 21, 2007 Share Posted June 21, 2007 (edited) Hi, I'm trying to automate a windows search dialog using DllCalls, and I've come upon a problem:I want to call this function: SHFindFiles, but it takes two tricky parameters: PCIDLIST_ABSOLUTE pidlFolder, PCIDLIST_ABSOLUTE pidlSaveFileReference can be found here: http://msdn2.microsoft.com/en-us/library/ms647744.aspxThe first parameter requires some kind of pid which I'm not really sure what it is, just that you can aquire it the function SHSimpleIDListFromPath.Reference can be found here: http://msdn2.microsoft.com/en-us/library/ms647928.aspxProblem is, that the SHSimpleIDListFromPath function returns a pointer to the id which I need for the first parameter in the SHFindFiles function.So, my question is this, how can I retrive the value from the pointer?This is the code I have so far(which doesn't work, because SHFindFiles doesn't expect a pointer, but the pid thing):Dim $PCIDLIST_ABSOLUT = DllCall("shell32.dll", "ptr&quÝË ][ÝÔÒÚ[RQÝÛT] ][ÝË ][ÝÝÜÝ][ÝË ][ÝÐÎÌLÉ]÷C² ¤bW'&÷"FVà¢×6t&÷ÂgV÷C´W'&÷"gV÷C²ÂW'&÷"¤VÇ6P¢×6t&à À°ÅÕ½ÐìÀÌØíA %1%MQ} M=1UPÅÕ½Ðì°ÀÌØíA %1%MQ} M=1UQlÁt¤)¹%((#036;Status = DllCall("shell32.dll", "int", "SHFin[É][ÝË ][ÝÚ[ ][ÝË ÌÍÔÒQTÕÐPÓÓU ][ÝÚ[ ][ÝË ][C²gV÷C² ¤bW'&÷"FVà¢×6t&÷ÂgV÷C´W'&÷"gV÷C²ÂW'&÷"¤VÇ6P¢5Í ½à À°ÅÕ½ÐìÀÌØíMÑÑÕÌÅÕ½Ðì°ÀÌØíMÑÑÕÍlÁt¤)¹%(Edit:The "pid" thing I was referring to is not a Process Identifier - just to clarify that. I would really appriciate any help. Edited June 21, 2007 by FreeFry Link to comment Share on other sites More sharing options...
FreeFry Posted June 21, 2007 Author Share Posted June 21, 2007 (edited) bump Anyone? or is it impossible (without a dll ) ? Edited June 21, 2007 by FreeFry Link to comment Share on other sites More sharing options...
FreeFry Posted June 24, 2007 Author Share Posted June 24, 2007 Sorry to bump this again, but it's of greater importance ( work related ) :/ I hope someone at least can say if it's not possible or not... Link to comment Share on other sites More sharing options...
FreeFry Posted January 23, 2008 Author Share Posted January 23, 2008 Hmm.. bump.. I know this is really old, but I hope someone could answer my question about it.. I still can't get it to work.. I noticed a few small errors, where parameter types (probably) should've been ptr instead of int, but still it doesn't work. :/ Link to comment Share on other sites More sharing options...
DaveF Posted January 24, 2008 Share Posted January 24, 2008 I feel that there'd be a simpler way to achieve your desired result in "pure" AutoIt; having said that I'm guessing that since this is shell functionality that you'd need to initialize COM (CoInitialize?) prior to calling the shell related functions. Just a guess... Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines. Link to comment Share on other sites More sharing options...
DaveF Posted January 24, 2008 Share Posted January 24, 2008 Yup. DLLCall("ole32.dll","int","CoInitialize","ptr",0) Dim $PCIDLIST_ABSOLUT = DllCall("shell32.dll", "ptr", "SHSimpleIDListFromPath", "wstr", "C:\Program Files") If @error Then MsgBox(0, "Error", @error) Else MsgBox(0, "$PCIDLIST_ABSOLUT", $PCIDLIST_ABSOLUT[0]) EndIf $Status = DllCall("shell32.dll", "int", "SHFindFiles", "ptr", $PCIDLIST_ABSOLUT[0], "ptr", 0) If @error Then MsgBox(0, "Error", @error) Else MsgBox(0, "$Status", $Status[0]) EndIf ; We're responsible for freeing the allocated PIDL DllCall("shell32.dll", "none", "ILFree", "ptr", $PCIDLIST_ABSOLUT[0]) Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines. Link to comment Share on other sites More sharing options...
FreeFry Posted January 24, 2008 Author Share Posted January 24, 2008 Thanks for the responses guys! That's exactly what I was looking for DaveF. I got a weird number back from the SHFindFiles function, and after a google on it, it turned up as some error regarding something not being initialized! Hmm, may I ask how you know that you had to do that before using that function? :| MSDN doesn't say anything about it. >_> Link to comment Share on other sites More sharing options...
DaveF Posted January 24, 2008 Share Posted January 24, 2008 Thanks for the responses guys!That's exactly what I was looking for DaveF.I got a weird number back from the SHFindFiles function, and after a google on it, it turned up as some error regarding something not being initialized!Hmm, may I ask how you know that you had to do that before using that function? :| MSDN doesn't say anything about it. >_>Mostly suspicion from past experience with Windows shell and COM functionality, but to verify I just googled for SHFindFiles and SHSimpleIDListFromPath (and also the data structure names referred to on their MSDN pages) until I found C++ examples to show the process of using these and similar functions. Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines. Link to comment Share on other sites More sharing options...
FreeFry Posted January 24, 2008 Author Share Posted January 24, 2008 (edited) I see.. I tried googling it too for examples, but I couldn't find any examples though. >_> Edit: So this is the code that I have now: expandcollapse popupOpt("WinTitleMatchMode", 4) DLLCall("ole32.dll","int","CoInitialize","ptr",0) Dim $struct_Folder, $struct_SaveFile Dim $struct_Folder = DllCall("shell32.dll", "ptr", "SHSimpleIDListFromPath", "wstr", @HomePath) If @error Then MsgBox(0, "Error", @error) _CleanUp() EndIf Dim $struct_SaveFile = DllCall("shell32.dll", "ptr", "SHSimpleIDListFromPath", "wstr", @ScriptDir & "\Test.fnd") If @error Then MsgBox(0, "Error", @error) _CleanUp() EndIf $Status = DllCall("shell32.dll", "int", "SHFindFiles", "ptr", $struct_Folder[0], "ptr", $struct_SaveFile[0]) If @error Then MsgBox(0, "Error", @error) _CleanUp() EndIf WinWait("[CLASS:CabinetWClass]") ControlClick("[LAST]", "", "Button5") _CleanUp() Func _CleanUp() DllCall("shell32.dll", "none", "ILFree", "ptr", $struct_Folder[0]) DllCall("shell32.dll", "none", "ILFree", "ptr", $struct_SaveFile[0]) Exit EndFunc And guess what? It works!! :} I wonder if there's any way to get the results from the search.. hmm In any case, it works, and that's just what I wanted. (It would be used on several computers for searching out image files/other personal files, that then could be copied to a backup location) Edited January 24, 2008 by FreeFry 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