<div class="content" name="RGetServiceKeyNameW" uuid="ecd403db-cc75-4402-a5fc-fcda46106205"><p>The RGetServiceKeyNameW method returns the <b>ServiceName</b>
of the <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_1fbb7936-8437-4e3d-b62f-47df3be07721" data-linktype="relative-path">service record</a></span> with
the specified <b>DisplayName</b>.</p><dl>
<dd>
<div><pre> 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
 );
</pre></div>
</dd></dl><p><b>hSCManager: </b>An <span><a href="b5f0a0a8-887c-4097-af1c-71ef9f214ce4" data-linktype="relative-path">SC_RPC_HANDLE (section 2.2.4)</a></span>
data type that defines the handle to the <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_afc3f782-a908-486d-9c05-8a054cd9cc84" data-linktype="relative-path">SCM</a></span> database created
using one of the open methods specified in section <span><a href="0d7a7011-9f41-470d-ad52-8535b47ac282" data-linktype="relative-path">3.1.4</a></span>.</p><p><b>lpDisplayName: </b>A pointer to a null-terminated <b>UNICODE</b>
string that specifies the service display name.</p><p><b>lpServiceName: </b>A pointer to a buffer that
receives the null-terminated <b>UNICODE</b> string that contains the service
name.</p><dl>
<dd>
<p>The forward slash, back slash, comma, and space
characters are illegal in service names.</p>
</dd></dl><p><b>lpcchBuffer: </b>A <b>DWORD</b> data type that
defines the pointer to a variable that specifies the size, in <span><a href="../ms-dtyp/9e7d8bfc-016c-48b7-95ae-666e103eead4" data-linktype="relative-path">wchar_t</a></span>s,
of the buffer. On output, this variable receives the size of the service name,
excluding the terminating null character.</p><p><b>Return Values: </b>The method returns 0x00000000
(ERROR_SUCCESS) on success; otherwise, it returns one of the following error
codes.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>123 ERROR_INVALID_NAME</td>
  <td>The name specified in the lpDisplayName parameter is invalid or set to NULL.</td>
 </tr><tr>
  <td>1060 ERROR_SERVICE_DOES_NOT_EXIST</td>
  <td>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.</td>
 </tr></tbody></table>
</dd></dl><p>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 <i>lpDisplayName</i>
parameter in the SCM database identified by <i>hSCManager</i>.</p><p>The server MUST return the ServiceName from the found
service record in the <i>lpServiceName</i> parameter and set the size in
wchar_ts of the service name excluding the terminating null character in the <i>lpcchBuffer</i>
parameter.</p><p>If the <i>lpServiceName</i> 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 <i>lpcchBuffer</i>
parameter. If the size is sufficient for data returned, the server also returns
the required size, in bytes.</p></div>