Compartir a través de


GetServiceHandle

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function returns the handle to a service instance based on its prefix.

This function is deprecated. To obtain a service handle, call CreateFile with the same prefix of the service whose handle must be retrieved.

Note

Do not use CreateFile to get the service handle if DeregisterService is called to unload the specified service. In this case, call GetServiceHandle to obtain the handle.

Syntax

HANDLE GetServiceHandle(
  LPWSTR szPrefix,
  LPWSTR szDllName,
  DWORD pdwDllBuf
);

Parameters

  • szPrefix
    [in] String that specifies the prefix of the service whose handle must be retrieved. This string is in the form XXXN:, where XXX is the prefix specified on either RegisterService or the prefix registry value read during ActivateService, and N is the index number. For example, the prefix HTP0: specifies the Web server.
  • szDllName
    [out] Optional. String that contains the name of the service DLL associated with szPrefix.
  • pdwDllBuf
    [in, out] Optional. Pointer to the DWORD that specifies the number of bytes in the szDllName buffer. On return, specifies the number of bytes written or the number of bytes required if the buffer is not large enough. This value includes the terminating NULL character.

Return Value

Returns a handle to the requested service on success and INVALID_HANDLE_VALUE on failure. To get extended error information, call GetLastError.

Remarks

This function returns the handle to a service instance based on its prefix. This function is deprecated. To obtain a service handle, call CreateFile with the same prefix of the service whose handle must be retrieved.

Requirements

Header service.h
Library coredll.lib
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

RegisterService
ActivateService

Other Resources

Services.exe
CreateFile