i seem to be having a problem with a function written for testing is a process is open
my process opener is this
that is working (it prints out terragen started, and th app does start)Code:bool C_terragen::launchTerragen() { string TMP_fullPath = configFile.SZ_config_tgpath; TMP_fullPath += "terragen.exe"; if(CreateProcess(TMP_fullPath.c_str(),NULL,NULL,NULL,0,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi)) { ttStartTime = time(NULL); cout<<"terragen started"<<endl; } else { cout<<"ERROR: unable to lauch terragen"; } }
my process killer is this
that WAS working untill i added the isRunning function to double check. which leads me to the function that is causing the problem...Code:bool C_terragen::killTerragen() { if(!TerminateProcess(pi.hProcess, 0)) { return(0); } else { if(isRunning()) { return(0); } else { return(1); } } }
this function always returns false. at first i thought it might be because it was called faster than the process starting up, but even pausing my program and resuming it when i could see the app fully loaded still returned falseCode:bool C_terragen::isRunning() { if (WaitForSingleObject(pi.hProcess, 1000) == WAIT_TIMEOUT) { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); return(0); } else { return(1); } }
pi is (suprise suprise) a PROCESS_INFORMATION structure
BTW. the application that is opened is susceptioble to quiting automaticly
if you have read down to here, then a massive thank you already, if you can give me an answer, that would be just grand![]()



LinkBack URL
About LinkBacks



