Getting the status of a service

Hi,
Assuming I know the name of a specific service and I want to know if it's running or if it's stopped.
Using Win32 or MFC, how can I do that ?
Shay
[187 byte] By [sharel] at [2007-11-19 18:27:44]
# 1 Re: Getting the status of a service
Try asking that question in
dev-archive Forums > Visual C++ & C++ Programming > Visual C++ Programming

This is a "Non Visual" forum

Regards
l00p1n6 at 2007-11-10 23:46:56 >
# 2 Re: Getting the status of a service
Yes you can, you use QueryServiceStatus

SC_HANDLE svHand = OpenSCManager(szServiceName, SERVICES_ACTIVE_DATABASE, SC_MANAGER_CONNECT);
SC_HANDLE svcHandle = OpenService(svHand , szServiceName, SERVICE_ALL_ACCESS);

SERVICE_STATUS svStatus;
BOOL bRet = QueryServiceStatus(svcHandle , &svStatus);
Jean-Guy2000 at 2007-11-10 23:47:57 >
# 3 Re: Getting the status of a service
See Service Function ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/service_functions.asp) in MSDN.
cilu at 2007-11-10 23:48:49 >
# 4 Re: Getting the status of a service
[ merged ]
[ deleted duplicate ]

Regards,
Siddhartha

PS: Sharel, please desist from posting the same questions across Forums.
Siddhartha at 2007-11-10 23:49:55 >