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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.