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.
Namespace: DevCase.Win32.NativeMethodsAssembly: 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
)
<DllImportAttribute("Kernel32.dll", CharSet := CharSet.Auto, BestFitMapping := false,
ThrowOnUnmappableChar := true, SetLastError := true>]
Public Shared Function SetComputerName (
computerName As String
) As Boolean
Dim computerName As String
Dim returnValue As Boolean
returnValue = Kernel32.SetComputerName(computerName)
public:
[DllImportAttribute(L"Kernel32.dll", CharSet = CharSet::Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
static bool SetComputerName(
[InAttribute] String^ computerName
)
[<DllImportAttribute("Kernel32.dll", CharSet = CharSet.Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)>]
static member SetComputerName :
computerName : string -> bool
No code example is currently available or this language may not be supported.
- 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
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.