how to close .exe

what is the code or function to close opening file.exe .. browser like chrome.exe or game.exe or what ever ?

i know the code to open file.exe

ShellExecute(0,
"open", // Operation to perform
"c:\\windows\\notepad.exe", // Application name
"c:\\example.txt", // Additional parameters
0, // Default directory
SW_SHOW);

Thank You .

Last edited on
Get a list of processes:
https://msdn.microsoft.com/en-us/library/ms682629(VS.85).aspx
For each process, get the filename:
https://msdn.microsoft.com/en-us/library/ms683217(v=vs.85).aspx
When you find the process you don't want, terminate it:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686714%28v=vs.85%29.aspx
Just be aware that Sarah Connor isn't that easy to kill.

By the way, this is highly dependent on your operating system - I can tell you're using Windows, so this should be in the Windows Programming section. You can click Edit Topic at the top of this page to fix that.
Last edited on
okay thank you for your comment and sry for late for replay .. i edited the topic as you said .. and i will check your links ..
thank you .
If you are spawning the process then already have he handle and you have full rights, no need to enumerate all running processes to get it.

However, ShellExecute will not give you the handle, use ShellExecuteEx or CreateProcess instead.
Thanks ..
i used this code
system("taskkill /F /T /IM file.exe");
Topic archived. No new replies allowed.