Installing Services via the Registry

In order to install a service on a machine, you must add a few values under the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services key in the registry.

Although you can install the service by directly manipulating the registry, you might want to use the CreateService() function. Listing 10.13 shows an example of calling the CreateService() function in order to install a service.

Code Listing 10.13. Example Using CreateService()
 void InstallAService(const char * szServiceName) { SC_HANDLE handle = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); char szFilename[256]; ::GetModuleFileName(NULL, szFilename, 255); SC_HANDLE hService = ::CreateService(handle, szServiceName, szServiceName, SERVICE_ALL_ACCESS, ...

Get COM+ Unleashed 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.