If I have a file path (that might be later passed to the ShellExecute
API) is there any way to tell if it points to an application?
I need this to work under Windows from a C++ program. Also, this path may contain start-up command line parameters.
If I have a file path (that might be later passed to the ShellExecute
API) is there any way to tell if it points to an application?
I need this to work under Windows from a C++ program. Also, this path may contain start-up command line parameters.
You can use the SaferiIsExecutableFileType function in order to check if the file is executable.
So you really want to know if a string that represents a command line has the path to an executable as its first "part". How you go about this kind of depends on how accurate you want the information to be.
First, you have to parse the string to get the first argument. It's not as simple as just looking for the first space, because Windows paths can contain spaces. You'll have to handle things like "c:\program files\internet explorer\iexplore.exe" "http://stackoverflow.com"
.
Searching for a file is a rather complicated process that involves searching the directories in the PATH environment variable. The SearchPath API function can help.