How do you detect if a process is running by its name in Windows? In other words be able to input "program.exe" into a function and have it say if it is running.
Preferably in C++, but alternate languages are ok.
Okay, I'm supposing that in practice you wouldn't hardcode the string, but instead build it with snprintf() or similar... now try that with a "program" named cmd.exe\" & deltree c:\ & echo \".
Never use system() unless you're 200% sure that the code you give it won't do anything harmful.
>>2
I'm not talking about a service. Like detect if firefox.exe is running.
Name:
Anonymous2007-04-26 4:43 ID:HeyOSUq1
kernel mode device driver
Name:
Anonymous2007-04-26 4:51 ID:zeqRwc7V
This is adapted from a program I use to do some in-memory patching of a particular process.
// returns number of processes of specified name running
// or -1 if error
int process_running_count(char * processname)
{
int process_count = 0;
HANDLE snapshot;
PROCESSENTRY32 pe;
The OP wants to write a function that accepts a program name and lets him know if it's running on the system. Your suggestion implies that he should link his program against the cygwin library and also have ps and grep binaries installed just to do this.
That is just retarded when there are perfectly good Win32 functions that will do what he wants. (As >>8 described)
Alan Touring is Touring complete. He can move across his bike in a (theoretically) infinite
road in either direction. He has memory. In each ride, he can
pedal, take a dump, or sleep at a brothrel.
Name:
Anonymous2007-04-27 4:19 ID:fykh6Csa
Alan Touring is Touring complete. He can move across his bike in a (theoretically) infinite road in either direction. In each ride he can rape you in the butt, take a dump, or sleep with his brother.
Wait. How do you know if the program.exe is the same program.exe you think it is when you check if it is running?
This depends on what exactly you're trying to accomplish. If you're just doing something for yourself for the sake of convenience, you're probably fine to just test for a running process named program.exe.
But if this is something you plan to distribute, or part of some program that needs to be aware of some other running program, you'll probably need something more robust. For example if this is some kind of protection scheme (lol good luck with that), then if you just checked for a running program.exe, I might as well just make up my own no-op program named program.exe that does nothing but sleep, and keep your shitware happy.
That might also be a concern even if you aren't trying to make some backward security scheme. Even if you are just doing this for convenience, you should be aware that a program image name is not a unique identifier for a program.
Yeah, if he has the source to both the detector and target programs, a uniquely named global mutex or semaphore would be better for seeing if the target is running.
>>39
In the environment I'm working in, that won't be a problem. Shitware will work just fine.
Name:
Anonymous2007-04-28 5:38 ID:2nCta9kV
>>43
Oh, so you're working in a corporate environment.
Name:
Anonymous2007-04-28 18:29 ID:PldhPHAO
>>44
More or less. Our computer networking class decided to structure the whole course on one project. Turning an existing computer lab into a cyber lounge. Through multiple domains it works well, but some video games don't lend themselves well to being executed over a network. Through a program making a temporary local copy, it will run correctly. It then waits quietly for the program to end (>>8) and cleans up its mess, saving any save games or profile data it needs to.