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