网站首页  词典首页

请输入您要查询的函数:

 

术语 getcomputernameex
释义 GetComputerNameEx
语法:
C++
BOOL WINAPI GetComputerNameEx(
__in COMPUTER_NAME_FORMAT NameType,
__out LPTSTR lpBuffer,
__inout LPDWORD lpnSize
);
GetComputerNameEx功能
检索一个NetBIOS或DNS名称与本地计算机相关的。名称建立在系统启动时,当系统从注册表中读取它们。
参数
NameType [in]
该类型的名称进行检索。此参数是从COMPUTER_NAME_FORMAT枚举类型值。下表提供的补充资料。
ValueMeaning
ComputerNameDnsDomainThe名称分配给本地计算机上的DNS域。如果本地计算机是一个群集节点,lpBuffer接收群集的DNS域名虚拟服务器。
ComputerNameDnsFullyQualifiedThe完全合格的DNS名称,唯一标识本地计算机。此名称是DNS主机名和DNS域名的组合,使用窗体HostName.DomainName。如果本地计算机是一个群集节点,lpBuffer接收群集的完全合格的DNS名称虚拟服务器。
ComputerNameDnsHostnameThe的DNS本地计算机的主机名。如果本地计算机是一个群集节点,lpBuffer接收群集的DNS主机名的虚拟服务器。
ComputerNameNetBIOSThe NetBIOS名称本地计算机。如果本地计算机是一个群集节点,lpBuffer接收群集的虚拟服务器的NetBIOS名称。
ComputerNamePhysicalDnsDomainThe名称分配给本地计算机上的DNS域。如果本地计算机是一个群集节点,lpBuffer接收本地计算机的DNS域名,而不是群集的虚拟服务器的名称。
ComputerNamePhysicalDnsFullyQualifiedThe完全合格的DNS名称唯一标识该计算机。如果本地计算机是一个群集节点,lpBuffer接收本地计算机的完全合格的DNS名称,而不是群集的虚拟服务器的名称。
完全合格的DNS名称的DNS主机名和DNS域名的组合,使用窗体HostName.DomainName。
ComputerNamePhysicalDnsHostnameThe的DNS本地计算机的主机名。如果本地计算机是一个群集节点,lpBuffer接收本地计算机的DNS主机名,而不是群集的虚拟服务器的名称。
ComputerNamePhysicalNetBIOSThe NetBIOS名称本地计算机。如果本地计算机是一个群集节点,lpBuffer接收本地计算机的NetBIOS名,而不是群集的虚拟服务器的名称。
lpBuffer [out]
阿一个缓冲区,它接收的计算机名称或群集的虚拟服务器名称的指针。
该名称的长度可能大于MAX_COMPUTERNAME_LENGTH字符,因为DNS允许较长的名称。为了确保此缓冲区足够大,设置此参数为NULL和使用所需的缓冲区大小的lpnSize参数中返回。
lpnSize [ in , out ]
在输入,指定缓冲区的大小TCHARs。在输出,收到了复制到目标缓冲区TCHARs数目不包括终止空字符。
如果缓冲区太小,函数失败并GetLastError返回ERROR_MORE_DATA。此参数得到了所需的缓冲区,包括终止空字符大小。
如果lpBuffer为NULL,这个参数必须是零。
返回值
如果函数成功,返回值是一个非零值。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。可能的值包括以下内容。
返回codeDescription
ERROR_MORE_DATAThe lpBuffer缓冲区太小。该lpnSize参数包含所需接受的名称字节数。
备注
如果组策略是不是本地计算机设置,GetComputerNameEx函数检索的NetBIOS或DNS在系统启动时确定的名称。如果组策略设置,则函数返回主域名通过组策略设置。由SetComputerName或SetComputerNameEx职能作出名称的更改不会生效,直到用户重新启动计算机。
如果本地计算机未配置为使用DNS名称,GetComputerNameEx不会回来的DNS信息。要配置计算机为此,请在操作系统的帮助中概述的步骤和更改主DNS后缀的计算机,然后重新启动计算机。
这个函数的行为可能会受到影响,如果在本地计算机是一个群集节点。有关更多信息,请参阅ResUtilGetEnvironmentWithNetName和UseNetworkName。
如果您正在使用的环境,使用不同的DNS布局,其中计算机的FQDN不匹配的域的FQDN,请使用LsaQueryInformationPolicy代替。
要编译的应用程序使用此函数,定义为0x0500或更高_WIN32_WINNT宏。有关详细信息,请参阅使用Windows头。
实例
#define _WIN32_WINNT 0x0500
#include
#include
#include
void _tmain(void)
{
TCHAR buffer[256] = TEXT("");
TCHAR szDescription[8][32] = {TEXT("NetBIOS"),
TEXT("DNS hostname"),
TEXT("DNS domain"),
TEXT("DNS fully-qualified"),
TEXT("Physical NetBIOS"),
TEXT("Physical DNS hostname"),
TEXT("Physical DNS domain"),
TEXT("Physical DNS fully-qualified")};
int cnf = 0;
DWORD dwSize = sizeof(buffer);
 
for (cnf = 0; cnf < ComputerNameMax; cnf++)
{
if (!GetComputerNameEx((COMPUTER_NAME_FORMAT)cnf, buffer, &dwSize))
{
_tprintf(TEXT("GetComputerNameEx failed (%d)\\n"), GetLastError());
return;
}
else _tprintf(TEXT("%s: %s\\n"), szDescription[cnf], buffer);
dwSize = sizeof(buffer);
ZeroMemory(buffer, dwSize);
}
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesGetComputerNameExW(Unicode)和GetComputerNameExA(ANSI)的
参见
计算机名称
COMPUTER_NAME_FORMAT
GetComputerName
ResUtilGetEnvironmentWithNetName
ResUtilSetResourceServiceStartParameters
ResUtilSetResourceServiceEnvironment
SetComputerName
SetComputerNameEx
系统信息功能
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==GetComputerNameEx Function
Retrieves a NetBIOS or DNS name associated with the local computer. The names are established at system startup, when the system reads them from the registry.
Syntax
C++
BOOL WINAPI GetComputerNameEx(
__in COMPUTER_NAME_FORMAT NameType,
__out LPTSTR lpBuffer,
__inout LPDWORD lpnSize
);
Parameters
NameType [in]
The type of name to be retrieved. This parameter is a value from the COMPUTER_NAME_FORMAT enumeration type. The following table provides additional information.
ValueMeaning
ComputerNameDnsDomainThe name of the DNS domain assigned to the local computer. If the local computer is a node in a cluster, lpBuffer receives the DNS domain name of the cluster virtual server.
ComputerNameDnsFullyQualifiedThe fully qualified DNS name that uniquely identifies the local computer. This name is a combination of the DNS host name and the DNS domain name, using the form HostName.DomainName. If the local computer is a node in a cluster, lpBuffer receives the fully qualified DNS name of the cluster virtual server.
ComputerNameDnsHostnameThe DNS host name of the local computer. If the local computer is a node in a cluster, lpBuffer receives the DNS host name of the cluster virtual server.
ComputerNameNetBIOSThe NetBIOS name of the local computer. If the local computer is a node in a cluster, lpBuffer receives the NetBIOS name of the cluster virtual server.
ComputerNamePhysicalDnsDomainThe name of the DNS domain assigned to the local computer. If the local computer is a node in a cluster, lpBuffer receives the DNS domain name of the local computer, not the name of the cluster virtual server.
ComputerNamePhysicalDnsFullyQualifiedThe fully qualified DNS name that uniquely identifies the computer. If the local computer is a node in a cluster, lpBuffer receives the fully qualified DNS name of the local computer, not the name of the cluster virtual server.
The fully qualified DNS name is a combination of the DNS host name and the DNS domain name, using the form HostName.DomainName.
ComputerNamePhysicalDnsHostnameThe DNS host name of the local computer. If the local computer is a node in a cluster, lpBuffer receives the DNS host name of the local computer, not the name of the cluster virtual server.
ComputerNamePhysicalNetBIOSThe NetBIOS name of the local computer. If the local computer is a node in a cluster, lpBuffer receives the NetBIOS name of the local computer, not the name of the cluster virtual server.

lpBuffer [out]
A pointer to a buffer that receives the computer name or the cluster virtual server name.
The length of the name may be greater than MAX_COMPUTERNAME_LENGTH characters because DNS allows longer names. To ensure that this buffer is large enough, set this parameter to NULL and use the required buffer size returned in the lpnSize parameter.
lpnSize [in, out]
On input, specifies the size of the buffer, in TCHARs. On output, receives the number of TCHARs copied to the destination buffer, not including the terminating null character.
If the buffer is too small, the function fails and GetLastError returns ERROR_MORE_DATA. This parameter receives the size of the buffer required, including the terminating null character.
If lpBuffer is NULL, this parameter must be zero.
Return Value
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError. Possible values include the following.
Return codeDescription
ERROR_MORE_DATAThe lpBuffer buffer is too small. The lpnSize parameter contains the number of bytes required to receive the name.

Remarks
If group policy is not set for the local machine, the GetComputerNameEx function retrieves the NetBIOS or DNS names established at system startup. If group policy is set, the function returns the primary domain name set by group policy. Name changes made by the SetComputerName or SetComputerNameEx functions do not take effect until the user restarts the computer.
If the local computer is not configured to use DNS names, GetComputerNameEx will not return DNS information. To configure the computer to do this, follow the steps outlined in the operating system help and change the primary DNS suffix of the computer, then restart the computer.
The behavior of this function can be affected if the local computer is a node in a cluster. For more information, see ResUtilGetEnvironmentWithNetName and UseNetworkName .
If you are working with environments that use different DNS layouts, where the computer's FQDN does not match the FQDN of its domain, use LsaQueryInformationPolicy instead.
To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0500 or later. For more information, see Using the Windows Headers .
Examples
#define _WIN32_WINNT 0x0500
#include
#include
#include
void _tmain(void)
{
TCHAR buffer[256] = TEXT("");
TCHAR szDescription[8][32] = {TEXT("NetBIOS"),
TEXT("DNS hostname"),
TEXT("DNS domain"),
TEXT("DNS fully-qualified"),
TEXT("Physical NetBIOS"),
TEXT("Physical DNS hostname"),
TEXT("Physical DNS domain"),
TEXT("Physical DNS fully-qualified")};
int cnf = 0;
DWORD dwSize = sizeof(buffer);
 
for (cnf = 0; cnf < ComputerNameMax; cnf++)
{
if (!GetComputerNameEx((COMPUTER_NAME_FORMAT)cnf, buffer, &dwSize))
{
_tprintf(TEXT("GetComputerNameEx failed (%d)\\n"), GetLastError());
return;
}
else _tprintf(TEXT("%s: %s\\n"), szDescription[cnf], buffer);
dwSize = sizeof(buffer);
ZeroMemory(buffer, dwSize);
}
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesGetComputerNameExW (Unicode) and GetComputerNameExA (ANSI)
See Also
Computer Names
COMPUTER_NAME_FORMAT
GetComputerName
ResUtilGetEnvironmentWithNetName
ResUtilSetResourceServiceStartParameters
ResUtilSetResourceServiceEnvironment
SetComputerName
SetComputerNameEx
System Information Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms724301(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:25:42