SetComputerNameA function

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 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 function.

Syntax

BOOL SetComputerNameA(
  LPCSTR lpComputerName
);

Parameters

lpComputerName

The computer name that will take effect the next time the computer is started. The name must not be longer than MAX_COMPUTERNAME_LENGTH characters.

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 returns ERROR_INVALID_PARAMETER.

Return Value

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

Applications using this function must have administrator rights.

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header sysinfoapi.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See Also

Computer Names

GetComputerName

GetComputerNameEx

SetComputerNameEx

System Information Functions