Platform SDK: DLLs, Processes, and Threads

GetServiceDisplayName

The GetServiceDisplayName function retrieves the display name of the specified service.

BOOL GetServiceDisplayName(
  SC_HANDLE hSCManager,  // handle to SCM database
  LPCTSTR lpServiceName, // service name
  LPTSTR lpDisplayName,  // display name
  LPDWORD lpcchBuffer    // size of display name buffer
);

Parameters

hSCManager
[in] Handle to a service control manager database, as returned by the OpenSCManager function.
lpServiceName
[in] Pointer to a null-terminated string that specifies the service name. This name is the same as the service's registry key name.
lpDisplayName
[out] Pointer to a null-terminated string that receives the service's display name. If the function fails, this buffer will contain an empty string.
lpcchBuffer
[in/out] Pointer to a variable that specifies the size, in TCHARs, of the buffer pointed to by lpDisplayName. On output, this variable receives the size, in TCHARs, of the service's display name, excluding the NULL terminator.

If the buffer pointed to by lpDisplayName is too small to contain the display name, the function does not store it. When the function returns, lpcchBuffer contains the size of the service's display name, excluding the NULL terminator.

Return Values

If the functions succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

There are two names for a service: the service name and the display name. The service name is the name of the service's key in the registry. The display name is a user-friendly name that appears in the Services control panel application, and is used with the NET START command. To map the service name to the display name, use the GetServiceDisplayName function. To map the display name to the service name, use the GetServiceKeyName function.

Requirements

  Windows NT/2000: Requires Windows NT 3.5 or later.
  Header: Declared in Winsvc.h; include Windows.h.
  Library: Use Advapi32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also

Services Overview, Service Functions, GetServiceKeyName, OpenSCManager