Original Post
🔒 Locked
Finding default program to open file type
Advertisement
On windows, you can just use the filename. For example, if I have an avi on my desktop of Ashlee Simpson making an utter fool of herself on SNL, I can just type "lipsync.avi" in the command prompt when in the desktop dir. It then performs the default action -which, for me, is to open it in my default avi viewing app and play the file.
system("lipsync.avi");
If I rename my file to "lipsync.flarg", and I have no default action for flarg files, then windows will ask me what I want to do with it.
I just double checked this works on Windows2000. I don't use XP so it is possible your mileage may vary.
system("lipsync.avi");
If I rename my file to "lipsync.flarg", and I have no default action for flarg files, then windows will ask me what I want to do with it.
I just double checked this works on Windows2000. I don't use XP so it is possible your mileage may vary.
Indeed, the registry. To check a filename's association, open up HKEY_CLASSES_ROOT\.bmp\(Default) to get some sort of name of the file type (I'm not completely sure what the interpretation of those names are). In this case, it is "Paint.Picture". So, to find the location of the executable associated with that file type, go to HKEY_CLASSES_ROOT\Paint.Picture\shell\edit\command\(Default) . Note that you should replace the "%1" with the name of the file you want Paint to open.
Hi, thanks both for the replies.
Flangazor - that did work although it was a bit odd as it opened a DOS prompt sat there for a while and then Photoshop loaded (this was for a .tga file). It may be acceptable although using the registry may ultimately be better - I will investigate....
Flangazor - that did work although it was a bit odd as it opened a DOS prompt sat there for a while and then Photoshop loaded (this was for a .tga file). It may be acceptable although using the registry may ultimately be better - I will investigate....
Quote:
Original post by Trip99
Hi, thanks both for the replies.
Flangazor - that did work although it was a bit odd as it opened a DOS prompt sat there for a while and then Photoshop loaded (this was for a .tga file). It may be acceptable although using the registry may ultimately be better - I will investigate....
use ShellExecuteEx().
system() is the DOS/C-Runtime style of spawning new processes - ShellExecuteEx() gives you a lot more control and is what you should be using for Windows based programs.
Another way to determine which program is used to open a particular file type, you can use FindExecutable() on the file in question.
Another advantage of using ShellExecuteEx() is you can specify the "verb" to use, such as "open", "edit", "print" etc.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement