GetServiceDisplayName

博客介绍了GetServiceDisplayName函数,该函数用于检索指定服务的显示名称。说明了函数的参数、返回值,若函数失败返回零,可调用GetLastError获取扩展错误信息。还提及服务有服务名和显示名,可通过该函数实现二者映射。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GetServiceDisplayName

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

BOOL GetServiceDisplayName(
  SC_HANDLE hSCManager,
  LPCTSTR lpServiceName,
  LPTSTR lpDisplayName,
  LPDWORD lpcchBuffer
);
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. It is best to choose a name that is less than 256 characters.
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.

The maximum size of this array is 4K bytes. To determine the required size, specify NULL for this parameter and 0 for the lpcchBuffer parameter. The function will fail and GetLastError will return ERROR_INSUFFICIENT_BUFFER. The lpcchBuffer parameter will receive the required size.

lpcchBuffer
[in, out] Pointer to a variable that specifies the size of the buffer pointed to by lpDisplayName, in TCHARs. On output, this variable receives the size of the service's display name, in TCHARs, excluding the null-terminating character.

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-terminating character.

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
ClientRequires Windows XP, Windows 2000 Professional, or Windows NT Workstation 3.5 and later.
ServerRequires Windows Server 2003, Windows 2000 Server, or Windows NT Server 3.5 and later.
Header

Declared in Winsvc.h; include Windows.h.

Library

Link to Advapi32.lib.

DLLRequires Advapi32.dll.
Unicode

Implemented as GetServiceDisplayNameW (Unicode) and GetServiceDisplayNameA (ANSI).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值