3.1.4.21 RGetServiceKeyNameW (Opnum 21)

The RGetServiceKeyNameW method returns the ServiceName of the service record with the specified DisplayName.

 DWORD RGetServiceKeyNameW(
   [in] SC_RPC_HANDLE hSCManager,
   [in, string, range(0, SC_MAX_NAME_LENGTH)] 
     wchar_t* lpDisplayName,
   [out, string, range(1, 4*1024+1), size_is(*lpcchBuffer+1)] 
     wchar_t* lpServiceName,
   [in, out] DWORD* lpcchBuffer
 );

hSCManager: An SC_RPC_HANDLE (section 2.2.4) data type that defines the handle to the SCM database created using one of the open methods specified in section 3.1.4.

lpDisplayName: A pointer to a null-terminated UNICODE string that specifies the service display name.

lpServiceName: A pointer to a buffer that receives the null-terminated UNICODE string that contains the service name.

The forward slash, back slash, comma, and space characters are illegal in service names.

lpcchBuffer: A DWORD data type that defines the pointer to a variable that specifies the size, in wchar_ts, of the buffer. On output, this variable receives the size of the service name, excluding the terminating null character.

Return Values: The method returns 0x00000000 (ERROR_SUCCESS) on success; otherwise, it returns one of the following error codes.

Return value/code

Description

123

ERROR_INVALID_NAME

The name specified in the lpDisplayName parameter is invalid or set to NULL.

1060

ERROR_SERVICE_DOES_NOT_EXIST

The service record with the DisplayName matching the value specified in the lpDisplayName parameter does not exist in the SCM database identified by the hSCManager parameter.

In response to this request from the client, for a successful operation the server MUST look up the service record with DisplayName matching the display name specified by the lpDisplayName parameter in the SCM database identified by hSCManager.

The server MUST return the ServiceName from the found service record in the lpServiceName parameter and set the size in wchar_ts of the service name excluding the terminating null character in the lpcchBuffer parameter.

If the lpServiceName buffer is insufficient to hold the complete service name of the service, the server MUST fail the call with ERROR_INSUFFICIENT_BUFFER (122) and set the size in wchar_ts of the service name excluding the terminating null character in the lpcchBuffer parameter. If the size is sufficient for data returned, the server also returns the required size, in bytes.