Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check if two process exist and close the last opened and show the firs

Status
Not open for further replies.

youssef

Programmer
Mar 13, 2001
96
BE
Hi,

I execute my pgm two times .
I would like to know how can I do for inhibe the second pgm execution
I would like to show the first pgm and close the second pgm.

Best Regards

 
Hi,
You do one thing,perhaps you might been trying to stop chil process from parent one.Code like this may help you where pi is another process embedded in main process.

WaitForSingleObject( pi.hProcess, INFINITE );
dwErr=GetLastError();
DWORD dwExitCode;
BOOL bExitCode=GetExitCodeProcess(pi.hProcess,&dwExitCode);

// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
TerminateProcess(pi.hProcess,dwExitCode);
 
A call to EnumWindows with your own function to search on the title of your application should do :)


CWnd *pWnd = 0;
::EnumWindows(YourEnumWindowsFunction, (LPARAM)pWnd);

That should get you started :)

matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top