Click to See Complete Forum and Search --> : Launch app from app


PUH
July 28th, 1999, 02:24 AM
Hi,

I would like to launch another app from my program. How can I do this ?

(Devstudio, MFC app)


Thanks !

PUH

ophirg
July 28th, 1999, 02:33 AM
Use CreateProcess(..)

Burlacu Ovidiu
July 28th, 1999, 02:58 AM
If app you want to launch requires parameters:


char str[] = app_to_launch + parameters
STARTUPINFO startup;
PROCESS_INFORMATION process;
memset( &startup, 0, sizeof( startup ) );
startup.cb = sizeof( startup );
memset( &process, 0, sizeof( process ) );
BOOL tSuccess = CreateProcess( NULL, str, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &process );
HWINSTA sta = GetProcessWindowStation();

if( tSuccess )
{
// Close the handles that CreateProcess returned so we don't leak
// kernel resources.
ASSERT( process.hProcess != NULL );
CloseHandle( process.hProcess );
ASSERT( process.hThread != NULL );
CloseHandle( process.hThread );
}




If not have parameters

CString str = app_to_launch
.............
BOOL tSuccess = CreateProcess( str, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &process );
.......................




hope this help you

Regards,
Ovidiu