//I have the CreateProcess function working but how do i get the handle to exit the process when the program is completed?
//program follows
#include “stdafx.h”
#undef NULL
#define NULL 0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
BOOL ret_bl;
STARTUPINFO sui;
PROCESS_INFORMATION pi;
sui.cb=sizeof(STARTUPINFO);
sui.wShowWindow=SW_SHOW;
ret_bl=CreateProcess(
NULL, // name of executable module
“Notepad.exe”, // command line string
NULL, // SD
NULL, // SD
NULL, // handle inheritance option
REALTIME_PRIORITY_CLASS, //creation flags
NULL, // new environment block
NULL, // current directory name
&sui, // startup information
&pi // process information
);
// BOOL GetExitCodeProcess(
// HANDLE hprocess, //handle to the process
// LPDWORD lpExitCode //termination status
// void ExitProcess(
// UINT uExitCode // exit code for all threads
// );
return 0;
}