Link to home
Start Free TrialLog in
Avatar of EMPHelpdesk
EMPHelpdesk

asked on

How do I open any file in C or C++` in its native application?

I want the user to type in the path of the file they want to open and have it run as if you double clicked it.  This is in windowsXP.

I know how to prompt the user and get the string they enter, but am having trouble with the opening part.  I have tried WinExec and CreateProcess which seems to work for opening a specific application but not for taking a variable to point to a specific file.

I would prefer the answer in C if it is possible. C++ if not.

Thank you

ASKER CERTIFIED SOLUTION
Avatar of josgood
josgood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ichijo
Ichijo

The easiest way I've found is to use ShellExecute: http://msdn2.microsoft.com/en-us/library/bb762153.aspx