Jump to content

API FindExecutable


ReFran
 Share

Recommended Posts

  • Moderators

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

; =================================================================================================
; 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 by PaulIA
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

  • Moderators

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

Wouldn'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

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 by PaulIA
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

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

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.

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

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.

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 extension

For example, with jpg or png file.

Registry gives you.

rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen %1

FindExecutable gives you

C:\WINDOWS\system32\shimgvw.dll

Edited by Joon
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...