Manjesh
asked on
How toi check if an EXE is running in background in Windows ??
Hi All,
Though this is a very common question I am bit confused in selecting the appropriate method.
The standard method of doing this is to implement a "Mutex" and use it across process. But the exe which I am trying to find out is 3rd party tool and they wont give out their mutex id.
So the other alternative is to list all the process name and execute a search on the result.
If any expert could sugget me a better alternative it would be great.
Thanks for your earliest attention.
Regards,
Manjesh Gowda S H
Though this is a very common question I am bit confused in selecting the appropriate method.
The standard method of doing this is to implement a "Mutex" and use it across process. But the exe which I am trying to find out is 3rd party tool and they wont give out their mutex id.
So the other alternative is to list all the process name and execute a search on the result.
If any expert could sugget me a better alternative it would be great.
Thanks for your earliest attention.
Regards,
Manjesh Gowda S H
What language are you working in here?...
You can use the FindWindow or EnumWindows function to search the windows by title.
using api
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
FindWindow(vbNullString, "Docsvault Professional") <- returns handle of that window..
search on FindWindow API.. u'll get it...
i might have used it in my program(i guess i dont remember things for looooooooong time) .. check following link...
http://www.codeproject.com/Purgatory/KzIPC.asp
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
FindWindow(vbNullString, "Docsvault Professional") <- returns handle of that window..
search on FindWindow API.. u'll get it...
i might have used it in my program(i guess i dont remember things for looooooooong time) .. check following link...
http://www.codeproject.com/Purgatory/KzIPC.asp
If something .Net, then see Process.GetProcessesByName ():
http://msdn2.microsoft.com/en-us/library/z3w4xdc9(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/z3w4xdc9(VS.80).aspx
ASKER
Sorry guys.. for the insufficient information.
Apart from the name of the exe I dont have an other information. So finding a window in the exe is out of question...
And the code in VC++, I am seeking for some kind of Win32 API.
Thanks for the quick reply...
Apart from the name of the exe I dont have an other information. So finding a window in the exe is out of question...
And the code in VC++, I am seeking for some kind of Win32 API.
Thanks for the quick reply...
hay you must be having the window caption?!!!! you can search it...
ASKER
even if there is window I cannot rely on it... Only the name of the exe will not change( thats what can be guaranteed)..
Thanks for the quick reply...
Thanks for the quick reply...
thats wat i mean
use spy++ in VS tool check windowcaption and keep it in findwindow
use spy++ in VS tool check windowcaption and keep it in findwindow
ASKER
I can do that ... tomm the entire window caption nay change or it might not have an UI at all...
I want to find out if the process is running only by its name and not use anything else.
So any other alternative ??
Thanks for your quick reply...
I want to find out if the process is running only by its name and not use anything else.
So any other alternative ??
Thanks for your quick reply...
a process must have some identity to find...
if window caption or classname changes u must search accordingly..
i dont think u can scan a same process with different name/class...
might give an alternative place to search an app.
U HAVE TO CHANGE ACCORDGLY THE EXE NAME/CLASSNAME
well you can also use WMI select query to find / fetch all processes but even it wont help if exe names keep changing.
if window caption or classname changes u must search accordingly..
i dont think u can scan a same process with different name/class...
might give an alternative place to search an app.
U HAVE TO CHANGE ACCORDGLY THE EXE NAME/CLASSNAME
well you can also use WMI select query to find / fetch all processes but even it wont help if exe names keep changing.
ASKER
No the exe wil never chage its guaranteed... I thought of using a tool or exe which will list the name of all the process and then execute a search for the exe name in the release.
May be I will try someting in WMI .... and specific function with in WMI whcih I can use...
Thanks for ur quick reply...
May be I will try someting in WMI .... and specific function with in WMI whcih I can use...
Thanks for ur quick reply...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Another option is to create a wrapper program around the .exe that you are looking for. You can give the wrapper an identity (mutex, window caption, processID, whatever) and then check to see if the wrapper is running.
ASKER
Mahesh tx for the soultion.. ur code has done my job.. thanks..