Kernel32SetComputerName Method

Sets a new NetBIOS name for the local computer.

The name is stored in the registry and the name change takes effect the next time the user restarts the computer.

If the local computer is a node in a cluster, SetComputerName(String) sets NetBIOS name of the local computer, not that of the cluster virtual server.

To set the DNS host name or the DNS domain name, call the SetComputerNameEx(ComputerNameFormat, String) function.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", CharSet = CharSet.Auto, BestFitMapping = false, 
	ThrowOnUnmappableChar = true, SetLastError = true)]
public static bool SetComputerName(
	string computerName
)

Parameters

computerName  String
The computer name that will take effect the next time the computer is started.

The standard character set includes letters, numbers, and the following symbols:

! @ # $ % ^ & ' ) ( . - _ { } ~ .

If this parameter contains one or more characters that are outside the standard character set, SetComputerName(String) returns ERROR_INVALID_PARAMETER

Return Value

Boolean
If the function succeeds, the return value is a .

If the function fails, the return value is .

To get extended error information, call GetLastWin32Error.

Remarks

See Also