PROCESS_INFORMATION g_procInfo;
BOOL RunIt(LPCSTR szExeFile, LPCSTR szArgs, BOOL bMinimized)
// call this function to run another program in a separate process
{
    UpdateData(TRUE);
    STARTUPINFO si;

    si.cb = sizeof(STARTUPINFO); 
    si.lpReserved=NULL; 
    si.lpDesktop = ""; 
    si.lpTitle = NULL; 
    si.dwFlags = STARTF_USESHOWWINDOW; 
    si.wShowWindow = bMinimized? SW_MINIMIZE : SW_NORMAL; 
    si.cbReserved2 = 0; 
    si.lpReserved2 = NULL; 
    return CreateProcess(szExeFile, szArgs, NULL, NULL,
                         FALSE, CREATE_NEW_CONSOLE|NORMAL_PRIORITY_CLASS, 
                         NULL, ".\\", &si, &g_procInfo);
}
BOOL HasExited()
// call this function to check if the process has exited 
{
     DWORD code;
     if (GetExitCodeProcess(g_procInfo.hProcess, &code)
         && code != STILL_ACTIVE)
     {
         return TRUE;
     }
     return FALSE;
}