Reputation: 26567
I need a way to open a generic file with the default application for that file.
For example: if the file is an HTML file, then it will be opened with Internet Explorer; if the file is an image (JPG, BMP, etc.), then it will be opened with "Paint"; if the file is an MP3 file, then it will be opened with Windows Media Player.
How can I do this ? What function or API do I have to use ?
Upvotes: 0
Views: 1086
Reputation: 125
Another solution is to use standard system
function - http://www.cplusplus.com/reference/clibrary/cstdlib/system/ so you won't even need to depend on WinAPI.
E.g.: system("start <filename>");
Upvotes: 1
Reputation: 13018
Use the ShellExecute function: http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx
EDIT: or ShellExecuteEx
Upvotes: 9