The GetComputerName function retrieves the computer name of the current system. This name is established at system startup, when it is initialized from the registry.
BOOL GetComputerName(
LPTSTR lpBuffer, // address of name buffer
LPDWORD nSize // address of size of name buffer
);
If the buffer is too small, the function fails, GetLastError returns ERROR_BUFFER_OVERRUN, and the variable returns the required buffer size including the terminating null character.
Windows 95 and Windows 98: GetComputerName fails if the input size is less than MAX_COMPUTERNAME_LENGTH + 1.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
System Information Overview, System Information Functions, SetComputerName