Export (0) Print
Expand All

SetComputerName 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 WINAPI SetComputerName(
  _In_  LPCTSTR lpComputerName
);

Parameters

lpComputerName [in]

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]

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

SetComputerNameW (Unicode) and SetComputerNameA (ANSI)

See also

Computer Names
GetComputerName
GetComputerNameEx
SetComputerNameEx
System Information Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft