provided by: 
Originally published at Internet.comI recently needed the code which displays all Windows NT services from the service database (kept in the registry) and for each service some essential information (service name, status etc.). As always, there are at least 2 possibilities. Instead of coding in the application, I created a small class which returns a pointer to the list of services. The contents of the list depends on the arguments supplied when enumerating services.
Class declaration: class TTrixServiceInfo { public : CString ServiceName; CString DisplayName; CString BinaryPath; DWORD ServiceType; DWORD StartType; DWORD ErrorControl; DWORD CurrentState; public : TTrixServiceInfo(); TTrixServiceInfo& operator =( const TTrixServiceInfo& source); CString GetServiceType( void ); CString GetStartType( void ); CString GetErrorControl( void ); CString GetCurrentState( void ); static TTrixServiceInfo *EnumServices(DWORD serviceType, DWORD serviceState,DWORD *count); };
Description:
Each object of this class contains information for one service. To build a list of services, execute the static function EnumServices(). There are several possibilities:
ServiceType is a bit OR combination of SERVICE_WIN32 and SERVICE_DRIVER...
Read article at Internet.com site