Click here to Skip to main content
15,909,030 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to check that if a file has been already opened Pin
Deepak Samuel11-Mar-04 1:35
Deepak Samuel11-Mar-04 1:35 
Questionhow to call a menu by clicking a button from a dialog? Pin
yeefarn11-Mar-04 0:57
yeefarn11-Mar-04 0:57 
AnswerRe: how to call a menu by clicking a button from a dialog? Pin
Tomasz Sowinski11-Mar-04 3:01
Tomasz Sowinski11-Mar-04 3:01 
AnswerRe: how to call a menu by clicking a button from a dialog? Pin
Roger Allen11-Mar-04 4:58
Roger Allen11-Mar-04 4:58 
GeneralParsing CString Pin
Caoimh11-Mar-04 0:46
Caoimh11-Mar-04 0:46 
GeneralRe: Parsing CString Pin
Robert A. T. Káldy11-Mar-04 1:00
Robert A. T. Káldy11-Mar-04 1:00 
GeneralRe: Parsing CString Pin
David Crow11-Mar-04 2:38
David Crow11-Mar-04 2:38 
GeneralTerminateProcess w2k and xp! Pin
ceuba11-Mar-04 0:46
ceuba11-Mar-04 0:46 
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
GeneralRe: TerminateProcess w2k and xp! Pin
Tomasz Sowinski11-Mar-04 3:06
Tomasz Sowinski11-Mar-04 3:06 
GeneralRe: TerminateProcess w2k and xp! Pin
ceuba11-Mar-04 3:33
ceuba11-Mar-04 3:33 
GeneralRe: TerminateProcess w2k and xp! Pin
Tomasz Sowinski11-Mar-04 3:46
Tomasz Sowinski11-Mar-04 3:46 
GeneralConvert CString to Unsigned Long Pin
Caoimh11-Mar-04 0:41
Caoimh11-Mar-04 0:41 
GeneralRe: Convert CString to Unsigned Long Pin
toxcct11-Mar-04 0:46
toxcct11-Mar-04 0:46 
GeneralRe: Convert CString to Unsigned Long Pin
David Crow11-Mar-04 2:39
David Crow11-Mar-04 2:39 
GeneralRe: Convert CString to Unsigned Long Pin
Steve S11-Mar-04 2:52
Steve S11-Mar-04 2:52 
GeneralRe: Convert CString to Unsigned Long Pin
Michael Haephrati12-Apr-15 9:39
professionalMichael Haephrati12-Apr-15 9:39 
Questionmust I port time critical code from Visual C++ 6.0 to 7.0 ? Pin
GuimaSun11-Mar-04 0:30
GuimaSun11-Mar-04 0:30 
AnswerRe: must I port time critical code from Visual C++ 6.0 to 7.0 ? Pin
Tomasz Sowinski11-Mar-04 2:54
Tomasz Sowinski11-Mar-04 2:54 
Generalsolve expression Pin
Member 169706311-Mar-04 0:25
Member 169706311-Mar-04 0:25 
GeneralRe: solve expression Pin
Prakash Nadar11-Mar-04 0:38
Prakash Nadar11-Mar-04 0:38 
GeneralRe: solve expression Pin
Robert A. T. Káldy11-Mar-04 0:56
Robert A. T. Káldy11-Mar-04 0:56 
GeneralRe: solve expression Pin
David Crow11-Mar-04 2:51
David Crow11-Mar-04 2:51 
GeneralConverting To Pixels Pin
Pazzuzu10-Mar-04 23:43
Pazzuzu10-Mar-04 23:43 
GeneralRe: Converting To Pixels Pin
Robert A. T. Káldy11-Mar-04 0:08
Robert A. T. Káldy11-Mar-04 0:08 
GeneralRe: Converting To Pixels Pin
Pazzuzu11-Mar-04 1:28
Pazzuzu11-Mar-04 1:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.