12.10. Enumerating Services

Windows 2000 offers two ways to enumerate services. Using the Enum ServicesStatus function, you can enumerate all of the available services. Using EnumDependentServices, you can enumerate the services that a specific service expects to have started before it starts. Listing 12.13 demonstrates the EnumServicesStatus function.

Code Listing 12.13. Enumerating available services
 // enum.cpp #include <windows.h> #include <iostream.h> void ErrorHandler(char *s, DWORD err) { cout << s << endl; cout << "Error number: " << err << endl; ExitProcess(err); } void main(int argc, const char *argv[]) { SC_HANDLE scm; BOOL success; LPENUM_SERVICE_STATUS status; DWORD numServices=0, sizeNeeded=0, resume=0; // Open a connection to ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.