Kernel32SetComputerNameEx Method

Sets a new NetBIOS or DNS name for the local computer.

Name changes made by SetComputerNameEx(ComputerNameFormat, String) do not take effect until the user restarts the computer.

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 SetComputerNameEx(
	ComputerNameFormat nameFormat,
	string computerName
)

Parameters

nameFormat  ComputerNameFormat
The type of name to be set.
computerName  String
The new name.

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

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