RegisterService (Windows CE 5.0)

Send Feedback

This function creates a new instance of a service.

HANDLE RegisterService(LPCWSTRlpszType,DWORD dwIndex,LPCWSTR lpszLib,DWORD dwInfo);

Parameters

  • lpszType
    [in] Pointer to the string that contains the three-letter service prefix code.
  • dwIndex
    [in] Specifies the service index number between 0 and 9.
  • lpszLib
    [in] Pointer to the string that contains the name of the DLL file that contains the service.
  • dwInfo
    [in] Specifies the argument passed during the call to the service's exposed xxx_Init (Services.exe) function.

Return Values

A handle to the service is returned on success. A NULL value is returned on failure. For extended error information, call GetLastError.

Remarks

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 (Services.exe), and xxx_IOControl (Services.exe) 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.

Note    RegisterService is available for use by trusted applications only. To avoid trust issues, it is recommended that you use the registry to set up your service, then call ActivateService to load the service.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Service.h.
Link Library: Coredll.lib.

See Also

xxx_Init (Services.exe) | xxx_Deinit (Services.exe) | xxx_IOControl (Services.exe) | Services.exe | Services.exe Registry Settings

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.