Hello Tomasz, thank you for your tip. I changed PROCESS_ALL_ACCESS to PROCESS_TERMINATE in OpenProcess(...). But i have the same effect as before. When i alredy had terminated the programm b.exe and it doesn't exist in the tast-manager. I do step 2 and the handle is alawy not NULL. But i see this effect only in XP. W2k show me NULL and I can start b.exe with createprocess. What do i wrong! Thanks Chris ceuba@gmx.net Student
ceuba
Posts
-
TerminateProcess w2k and xp! -
TerminateProcess w2k and xp!VC6.0 Hello, i have a question, how can i terminate a process from an another process? Ich my Situation i want start program b.exe from a.exe. But b.exe should start once a time! I do it with that: 1) First start b.exe: PROCESS_INFORMATION ProcInfo; STARTUPINFO startupInfo; memset(&startupInfo, 0, sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); CreateProcess(NULL, // lpApplicationName "C:\\b.exe", // lpCommandLine NULL, // lpProcessAttributes NULL, // lpThreadAttributes NULL, // bInheritHandles NULL, // dwCreationFlags NULL, // lpEnvironment NULL, // lpCurrentDirectory &startupInfo, // lpStartupInfo ProcInfo); // lpProcessInformation 2) Second i check, wheter program is still activ HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS,TRUE,pProcInfo->dwProcessId); if (handle!=NULL) { ... if programm b.exe activ terminate b.exe ... } else { ... start b.exe ... } 3) If programm b.exe active i terminate it and restart it I do it with this code: TerminateProcess(m_pProcInfo->hProcess, 0); Now i got back to step 1: This works fine in w2k, but in xp step 2 doesn't work. The handle is always not NULL. What is wrong? Give's a better way to do that? Thanks Chris Student
-
Unable to capture ENTER key on a CEdit ControlYou can catch the ENTER key in your own edit control class in PreTranslateMessage: BOOL MyClass::PreTranslateMessage(MSG* pMsg) { if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) { DoAnything(); or // pMsg->wParam=0; } return CDialog::PreTranslateMessage(pMsg); } Student