This function creates a new instance of a service.
HANDLE RegisterService( LPCWSTR lpszType, DWORD dwIndex, LPCWSTR lpszLib, DWORD dwInfo );
[in] Pointer to the string that contains the three-letter service prefix code.
[in] Specifies the service index number between 0 and 9.
[in] Pointer to the string that contains the name of the DLL file that contains the service.
[in] Specifies the argument passed during the call to the service's exposed xxx_Init function.
A handle to the service is returned on success. A NULL value is returned on failure. For extended error information, call GetLastError.
RegisterService can be used to either load an unloaded service into memory or create a new instance of a service already loaded.
RegisterService will first load the DLL file specified in lpszLib and verify that it exports the xxx_Init, xxx_Deinit, and xxx_IOControl functions. RegisterService will fail with ERROR_FILE_NOT_FOUND if the DLL file cannot be loaded and ERROR_INVALID_FUNCTION if the file does not export the required functions.
Varying instances of a service running from the same DLL and with the same lpszType value are differentiated by different dwIndex values. These values must be unique for a given service. RegisterService will verify that no service has the same lpszType prefix and dwIndex value. If this is the case, it will fail and SetLastError to ERROR_DEVICE_IN_USE.
Services.exe will then call the xxx_Init function and pass it the value stored in dwInfo. If the service returns a value of zero, Services.exe will fail and SetLastError to ERROR_OPEN_FAILED. Otherwise, it will store the return value of xxx_Init and pass it as a context value at a later time when calling another function of the service such as xxx_Deinit and xxx_IOControl.
OS Versions: Windows CE .NET 4.0 and later.
Link Library: Coredll.lib.
Last updated on Saturday, April 10, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.