The Database Managers, Inc.

Contact The Database Managers, Inc.

Use an RSS enabled news reader to read these articles.Use an RSS enabled news reader to read these articles.

Running other programs

by Curtis Krauskopf

Date: Fri, 4 Jun 1999 16:20:13 -0500
(copied and edited from a message posted on borland.public.cpp.language )

For Win16 targets use WinExec("Explorer.exe", SW_SHOW); 
For DOS and Win32 you may use: system, spawn or CreateProcess, system is simplest one: system("Explorer.exe");

More about running other programs

Date: Wed, 09 Jun 1999 06:59:31 -0400
(copied and edited from a message posted on borland.public.cppbuilder.language

Basically you have 3 options:

1) The easiest way to run an arbitrary application is to use the Win32 API call WinExec.  You build the command line and then you just run it.  It doesn't give you much control over how it runs, besides the 2nd CmdShow parameter, but it is easy to use.  Just ignore the "provided for compatibility with earlier versions of Windows" in the help file - it ain't going anywhere.

2) Go up the ladder in control to the suggest CreateProcess API call.  This one has a monstrous number of parameters, but you get lots of control in return, including some info so you can wait on it and such.

3) If you want to launch an application, like a web browser, that the user has associated with a particular type of file, like a URL, you use the ShellExec Win32 API.  Here's a simple example to start up the users web browser on a URL:

char* URL = "";
// Now just use ShellExecute to run it
rcode = ShellExecute( NULL, "open", URL, NULL, "C:\\", SW_SHOW );

All of these functions can be found in your Win32.hlp file. 

Popular C++ topics at The Database Managers:

C++ FAQ Services | Programming | Contact Us | Recent Updates
Send feedback to: