ReFran Posted December 22, 2006 Share Posted December 22, 2006 Hi,I got a hint for a API call "FindExecutable". Can this be used from AutoIt and how.http://msdn.microsoft.com/library/default....dexecutable.aspbest regards, Reinhard Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 22, 2006 Moderators Share Posted December 22, 2006 Anything wrong with ProcessList()? You may want to iterate exactly what you are trying to accomplish. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
ReFran Posted December 22, 2006 Author Share Posted December 22, 2006 Anything wrong with ProcessList()? ......I want to find out which programm will start based on file association, when I use Run oder shellexecute for a PDF file.br, Reinhard Link to comment Share on other sites More sharing options...
PaulIA Posted December 22, 2006 Share Posted December 22, 2006 (edited) ; ================================================================================================= ; Description ..: Retrieves the name of the executable file associated with the specified file name ; Parameters ...: $FileName - Fully qualified path to existing file ; $Directory - Default directory ; Return values : Full path to the executable file started when an "open" by association is run on the ; file specified or blank if no association was found ; Author .......: Paul Campbell (PaulIA) ; Notes ........: ; ================================================================================================= Func _API_FindExecutable($sFileName, $sDirectory="") Local $rBuffer $rBuffer = DllStructCreate("char[4096]") DllCall("Shell32.dll", "hwnd", "FindExecutable", "str", $sFileName, "str", $sDirectory, "ptr", DllStructGetPtr($rBuffer)) Return DllStructGetData($rBuffer, 1) EndFunc Edited December 22, 2006 by PaulIA Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 22, 2006 Moderators Share Posted December 22, 2006 I want to find out which programm will start based on file association, when I use Run oder shellexecute for a PDF file.br, ReinhardWouldn't that be located in your registry settings? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Joon Posted December 22, 2006 Share Posted December 22, 2006 Wouldn't that be located in your registry settings? Yes. Func _DefaultProgramByExtension($ext) Local $ContentType $ContentType = RegRead("HKEY_CLASSES_ROOT\." & $ext,"") Return RegRead("HKEY_CLASSES_ROOT\" & $ContentType & "\Shell\Open\Command","") EndFunc Link to comment Share on other sites More sharing options...
PaulIA Posted December 22, 2006 Share Posted December 22, 2006 (edited) You need to be careful with the registry approach. For example, when you query the registry for a handler for "doc", it returns: "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE" /n /dde When you query using FindExecutable, you will get C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE You may or may not get the results that you expect with the registry. You'll always get the path to the executable using FindExecutable. Edited December 22, 2006 by PaulIA Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
ReFran Posted December 22, 2006 Author Share Posted December 22, 2006 Great! Both solutions are working fine! To set up an API call is far about my scripting level (at least if I don't want to take some days free). Thanks Paul. Joon, I really wondered that it can be done so quick. I thought about it, but wasn't shure which key would be to query. It's important to know which program will start, so I can handle the file. Personal I work with Acrobat v5, Reader7 and from time to time with FoxitReader. Thanks all, Reinhard Link to comment Share on other sites More sharing options...
ReFran Posted December 22, 2006 Author Share Posted December 22, 2006 You need to be careful with the registry approach. For example, when you query the registry for a handler for "doc", it returns:"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE" /n /ddeWhen you query using FindExecutable, you will getC:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXEYou may or may not get the results that you expect with the registry. You'll always get the path to the executable using FindExecutable.Thanks for the hint. Acrobat has another special, if one version is opened, it's take over independed from the file association. So I've also to check the ProcessList().br, Reinhard Link to comment Share on other sites More sharing options...
Joon Posted December 23, 2006 Share Posted December 23, 2006 (edited) You need to be careful with the registry approach. For example, when you query the registry for a handler for "doc", it returns:"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE" /n /ddeWhen you query using FindExecutable, you will getC:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXEYou may or may not get the results that you expect with the registry. You'll always get the path to the executable using FindExecutable.True, but there are pro and cons. FindExecutable give straight path to the file but not always workable. Registry will gives you the method it's going to launch the application that is associate with extensionFor example, with jpg or png file.Registry gives you. rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen %1FindExecutable gives youC:\WINDOWS\system32\shimgvw.dll Edited December 23, 2006 by Joon 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