Re: Fails to terminate SystemInfo(msInfo32.exe) programatically
- From: Grzegorz Wróbel </dev/null@xxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 16 Feb 2007 14:09:56 +0100
FindWindow() was just an example.
If your program is a general purpose launcher (and Msinfo32.exe was used only as an example?) you can try the following:
Enumerate all top level windows and call GetWindowThreadProcessId() for each. If the returned process id match the one returned by ShellExecuteEx/CreateProcess then you have the handle of the window you want to close. You can send WM_CLOSE now. (But notice that many applications may display some confirmation dialog before quiting, so if you are determined to close the app anyway you might have no choise but to use TerminateProcess() if after some timeout after sending WM_CLOSE an apllication is stiill there.)
Indu wrote:
Grzegorz , thanks for replying to my post.
The applications that needs to be launched is taken us an input from the user. If I have to use FindWindow call to terminate the applications then, we should know the title of the applications also. But, we can not mandate the user to provide the title along with the applications.
How should I resolve this issue. I have only the list of applications with their path as an input. I should launch and terminate them.
"Grzegorz Wróbel" wrote:
Indu wrote:Hi,Indu, you should read the Remarks section in MSDN to find out why you shouldn't use TerminateProcess unless you really have too.
MsInfo32.exe is a Microsoft application. I am launching it from my application using ShellExcecuteEx API. This call just returns me an hProcess. I am using this handle to a process to terminate it , using TerminateProcess() API.
Other than hProcess, i have no other information about the process.
Using this approach I am successful in launching and terminating various other Microsoft applications like regedit.exe,Ntepad.exe, services.msc etc.
You can obtain HWND of MsInfo32.exe for example by calling FindWindow("PCHShell Window","System Information");
PS. GDI is not the right newsgroup for this question (I though I was reading it on comp.os.ms-windows.programmer.win32).
--
Grzegorz Wróbel
http://www.4neurons.com/
677265676F727940346E6575726F6E732E636F6D
--
Grzegorz Wróbel
http://www.4neurons.com/
677265676F727940346E6575726F6E732E636F6D
.
- References:
- Re: Fails to terminate SystemInfo(msInfo32.exe) programatically
- From: Grzegorz Wróbel
- Re: Fails to terminate SystemInfo(msInfo32.exe) programatically
- From: Grzegorz Wróbel
- Re: Fails to terminate SystemInfo(msInfo32.exe) programatically
- Prev by Date: Re: Device fonts and Font Cartridges
- Next by Date: Re: Unmanaged GDI+ flicker problem
- Previous by thread: Re: Fails to terminate SystemInfo(msInfo32.exe) programatically
- Next by thread: Re: How to programatically capture the Full webpage ?
- Index(es):
Relevant Pages
|