xRobot
xRobot

Reputation: 26567

How to open a generic file?

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

Answers (2)

asciz
asciz

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

ZippyV
ZippyV

Reputation: 13018

Use the ShellExecute function: http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx

EDIT: or ShellExecuteEx

Upvotes: 9

Related Questions