|
-
November 6th, 2002, 04:39 AM
#1
To find if a process is running.
Hi Techies,
Can anyone tell me an API or a logic to find if a process is running on a system (local and remote). The problem is detailed below:
1. I launch an application say "Notepad.exe" from another application say "MyApp".
2. Notepad.exe continues to run after I close "MyApp".
3. The second time I run "MyApp", it should check if there is already an instance of "Notepad.exe" running. If yes, it should not launch it.
From the code I will be passing only the application name "Notepad.exe". I am not creating a thread. Is there a single API call which takes the application name and tells if the application is already running in the system [OR] is there a simple method to find this out.
Regards,
KalpanaManuPrasad
-
November 6th, 2002, 04:47 AM
#2
Hi,
I think the api function "FindWindow" should help you.
Winni
-
November 6th, 2002, 04:58 AM
#3
Use API functions Process32First, Process32Next to iterate through all opened processes.
-
November 6th, 2002, 07:15 AM
#4
1. Process32First, Process32Next does not work on Win NT for ex.
It's special for Win 9x ( in ToolHelp lib ) and else Win 2000... supports it. So for Win NT there are functions from psapi.dll ( EnumProcesses,...), PDH-functions and hidden hive of registry (HKEY_PERFORMANCEDATA). There is no one way to enumerate processes for all Win-platforms.
2. If FindWindow,
There is one question: Are U simple need already running notepad.exe or it must be notepad.exe with some information from previsious process ( opened document in it for ex. ).
Because U can have situation when U have many notepad.exe running on machine, so if you want to find notepad.exe running by your process U must know for ex. a caption of this notepad window. And use it for finding current notepad instance.
"UNIX is simple; it just takes a genius to understand its simplicity!"
-
November 6th, 2002, 07:58 AM
#5
OSVERSIONINFO os;
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&os);
if (os.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
}
else if (os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
}
else
{
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|