12.5. Installing and Removing a Service

In order to use the beep service described in the previous section, you have to install it. Installation makes the SCM aware of the service and causes the SCM to add it to the list of services that appears in the Services Applet of the Control Panel. The code shown in Listing 12.2 demonstrates how to install a service.

Code Listing 12.2. Installing a service
 // install.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, char *argv[]) { SC_HANDLE newService, scm; if (argc != 4) { cout << "Usage:\n"; cout << " install service_name \ service_label executable\n"; cout << " ...

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.