Skip to content

Latest commit

 

History

History
174 lines (122 loc) · 6.26 KB

nf-sysinfoapi-setcomputernameexw.md

File metadata and controls

174 lines (122 loc) · 6.26 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:sysinfoapi.SetComputerNameExW
SetComputerNameExW function (sysinfoapi.h)
Sets a new NetBIOS or DNS name for the local computer. (Unicode)
ComputerNamePhysicalDnsDomain
ComputerNamePhysicalDnsHostname
ComputerNamePhysicalNetBIOS
SetComputerNameEx
SetComputerNameEx function
SetComputerNameExW
_win32_setcomputernameex
base.setcomputernameex
sysinfoapi/SetComputerNameEx
sysinfoapi/SetComputerNameExW
base\setcomputernameex.htm
winprog
12163456-770c-4f9e-9261-a6ea5f2cd93a
12/05/2018
ComputerNamePhysicalDnsDomain, ComputerNamePhysicalDnsHostname, ComputerNamePhysicalNetBIOS, SetComputerNameEx, SetComputerNameEx function, SetComputerNameExA, SetComputerNameExW, _win32_setcomputernameex, base.setcomputernameex, sysinfoapi/SetComputerNameEx, sysinfoapi/SetComputerNameExA, sysinfoapi/SetComputerNameExW
sysinfoapi.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
SetComputerNameExW (Unicode) and SetComputerNameExA (ANSI)
Kernel32.lib
Kernel32.dll
Windows
19H1
SetComputerNameExW
sysinfoapi/SetComputerNameExW
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-SysInfo-l1-2-0.dll
KernelBase.dll
API-MS-Win-Core-SysInfo-l1-2-1.dll
API-MS-Win-Core-SysInfo-l1-2-2.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
MinKernelBase.dll
API-MS-Win-Core-SysInfo-l1-2-3.dll
SetComputerNameEx
SetComputerNameExA
SetComputerNameExW

SetComputerNameExW function

-description

Sets a new NetBIOS or DNS name for the local computer. Name changes made by SetComputerNameEx do not take effect until the user restarts the computer.

-parameters

-param NameType [in]

The type of name to be set. This parameter can be one of the following values from the COMPUTER_NAME_FORMAT enumeration type.

Value Meaning
ComputerNamePhysicalDnsDomain
Sets the primary DNS suffix of the computer.
ComputerNamePhysicalDnsHostname
Sets the NetBIOS and the Computer Name (the first label of the full DNS name) to the name specified in lpBuffer. If the name exceeds MAX_COMPUTERNAME_LENGTH characters, the NetBIOS name is truncated to MAX_COMPUTERNAME_LENGTH characters, not including the terminating null character.
ComputerNamePhysicalNetBIOS
Sets the NetBIOS name to the name specified in lpBuffer. The name cannot exceed MAX_COMPUTERNAME_LENGTH characters, not including the terminating null character.

Warning: Using this option to set the NetBIOS name breaks the convention of interdependent NetBIOS and DNS names. Applications that use the DnsHostnameToComputerName function to derive the NetBIOS name from the first label of the DNS name will fail if this convention is broken.

-param lpBuffer [in]

The new name. The name cannot include control characters, leading or trailing spaces, or any of the following characters: " / \ [ ] : | < > + = ; , ?

-returns

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.

-remarks

SetComputerNameEx can set the Computer Name (the first label of the full DNS name) or the primary DNS suffix of the local computer. It cannot set a fully qualified DNS name in one call.

If the local computer is a node in a cluster, SetComputerNameEx sets NetBIOS or DNS name of the local computer, not that of the cluster virtual server.

The process that calls the SetComputerNameEx function must have administrator privileges on the local computer.

To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later. For more information, see Using the Windows Headers.

Note

The sysinfoapi.h header defines SetComputerNameEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

COMPUTER_NAME_FORMAT

Computer Names

DnsHostnameToComputerName

GetComputerName

GetComputerNameEx

SetComputerName

System Information Functions