Discussion:
Cross-session detection of running programs
(too old to reply)
Rob
2008-07-18 19:09:00 UTC
Permalink
One of our applications and a couple of our installers need to be able to
determine whether or not certain programs are running. They do that using
FindWindow(), as in this article: <http://support.microsoft.com/kb/88167>.
The problem is, Vista came along and bit us in the butt, because one of the
programs that wee need to detect is actually a service, and our detection
routine no longer detects whether or not that is running.

Is there a more reliable way to detect whether or not a program or service
is running that works across session boundaries and doesn't involve a whole
lot of pain. It should not involve .NET or anything else that has to be
installed onto an XP or Win2k system in order for it to work. (This is a
requirement for the installer; we don't want the installer to have any
prerequisites that are not present out of the box on our earliest supported
OS, which is Win2k in the version of our programs that we're currently in the
process of getting into beta. Also, as we are using Visual Studio 6 for the
development of that version, the solution must be compatible with that (i.e.,
using only Win32 API and/or MFC calls).)
LT Khoo
2008-08-13 07:37:01 UTC
Permalink
Hi Rob,

I noticed no reply to your thread for quite some time. Have you found the
solution ?

I am not very familiar with VB but in VC6, I use some functions to detect a
running window service reliably in all windows versions. They are windows sdk
functions to be used together but I don't know if you can access them using
VB.

OpenSCManager
OpenService
QueryServiceStatus

As I used them in C, I don't have any code extract example in VB. Wonder if
this help.

ltkhoo
Post by Rob
One of our applications and a couple of our installers need to be able to
determine whether or not certain programs are running. They do that using
FindWindow(), as in this article: <http://support.microsoft.com/kb/88167>.
The problem is, Vista came along and bit us in the butt, because one of the
programs that wee need to detect is actually a service, and our detection
routine no longer detects whether or not that is running.
Is there a more reliable way to detect whether or not a program or service
is running that works across session boundaries and doesn't involve a whole
lot of pain. It should not involve .NET or anything else that has to be
installed onto an XP or Win2k system in order for it to work. (This is a
requirement for the installer; we don't want the installer to have any
prerequisites that are not present out of the box on our earliest supported
OS, which is Win2k in the version of our programs that we're currently in the
process of getting into beta. Also, as we are using Visual Studio 6 for the
development of that version, the solution must be compatible with that (i.e.,
using only Win32 API and/or MFC calls).)
Rob
2008-08-13 16:49:03 UTC
Permalink
Post by LT Khoo
Hi Rob,
I noticed no reply to your thread for quite some time. Have you found the
solution ?
I am not very familiar with VB but in VC6, I use some functions to detect a
running window service reliably in all windows versions. They are windows sdk
functions to be used together but I don't know if you can access them using
VB.
OpenSCManager
OpenService
QueryServiceStatus
As I used them in C, I don't have any code extract example in VB. Wonder if
this help.
ltkhoo
I ended up calling CreateToolhelp32Snapshot() and searching the list of
processes that it generated for the program(s) that I'm interested in.
Calling the function with TH32CS_SNAPPROCESS as the first parameter gets me
the running processes. To get further details of a process (such as the path
of the executable), I call it with TH32CS_SNAPMODULE and the process ID of
the process I want to focus in on. (I only do that if the executable file of
a process is one of the ones that I'm looking for; I get the details in order
to confirm whether or not the process really is what I'm looking for.)
Loading...