Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to launch a file with the default program

Status
Not open for further replies.

wimvanherp

Programmer
Mar 3, 2001
149
BE
I'd like to launch a file with the default program that is assigned for it, f.i .wav -> mediaplayer, .doc ->word ...
I tried the launch the function start blabala.wav from within my program (f.i. with winexec or spawn) but start.exe does not exist anymore in NT. In Win98 it exists but in NT you can use the startfunction in a dosbox but not within a program. So does anybody know a function to do the same without having to look for the default program that is assigned to a particular extension. And if that does not exist, how do I find the default program that is assigned with a particular extension ?
 
I'm not so sure if this will work in NT, but it does work in 98..

Use the API 'ShellExecute' to open a file!

HINSTANCE ShellExecute(
HWND hwnd, // handle to parent window
LPCTSTR lpOperation, // pointer to string that specifies operation to perform
LPCTSTR lpFile, // pointer to filename or folder name string
LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
LPCTSTR lpDirectory, // pointer to string that specifies default directory
INT nShowCmd // whether file is shown when opened
);

You must include shellapi.h before using it!
#include <shellapi.h> Martin G Broman
mgb_svea@thevortex.com

DWS - Alpha Whitin Dead Wolf Society
 
Thanks a lot, it works allright, also in NT Wim Vanherp
Wim.Vanherp@myself.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top