Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect if a service is running in Vista? EnumWindows?

Status
Not open for further replies.

fyndor

Programmer
Apr 25, 2007
3
US
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.
 
Search in MSDN Library for the system-service functions mentioned beneath. You should call :

- 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top