Class for Enumerating NT Services






4.60/5 (7 votes)
Dec 8, 1999

52862

1920
A Class for enumerating NT services and drivers
The purpose of this class is to enumerate NT services on a local machine. You can specify the following criteria for service enumeration:
- Do you want to enumerate NT services or NT drivers.
- Do you want to enumerate active or inactive services and or drivers.
The class is designed to work with STL classes. In fact, there are 2 EnumServices functions. One that returns a pointer to a list of objects (in this case caller is responsible to delete this pointer using delete []) and another that returns an STL list containing service objects.
Sample using STL list
TNtServiceInfoList srvList; TNtServiceInfo::EnumServices(SERVICE_WIN32, SERVICE_ACTIVE, &srvList); TNtServiceInfoList::iterator it; for (it = srvList.begin(); it != srvList.end(); it ++) { TNtServiceInfo *pInfo = &(*it); // Do something }