Detect if a service is running in Vista? EnumWindows?
Detect if a service is running in Vista? EnumWindows?
(OP)
I work for a company who is trying to make their software package work with Vista. We used to use its built-in function FindWindow to check if a certain service was running at the time of install. Pre-Vista this worked properly but on vista machines this function returns that the service is not running when it is. I assume FindWindow is making use of the EnumWindows API call and checking this list for the service they are looking for. I wrote a Delphi program to list everything returned by EnumWindows. When I run it on an XP box it returns all normal programs and services, but in Vista it does not include the services. I think this is the reason that InstallShield's function FindWindow does not work for detecting a Vista service, because they probably used EnumWindows API and it doesn't work to detect services anymore. So I need to write a DLL or something to check to see if a certain service is running. How can I do this with Delphi (we use D5) and Vista? Keep in mind I am developing on an XP machine not a Vista machine so I hope thats not a problem.
RE: Detect if a service is running in Vista? EnumWindows?
- OpenSCManager to connect to the services database
- OpenService to get a handle to the service(s) of interest
- QueryStatus to find out if it is running
- CloseServiceHandle to close the "OpenService" handle
- CloseServiceHandle to close the "OpenSCManager" handle
Marcel