GetComputerNameW function
Retrieves the standard, NetBIOS, or DNS name of the local computer.
Syntax
BOOL GetComputerNameW(
LPWSTR lpBuffer,
LPDWORD nSize
);
Parameters
| Parameter | Description |
|---|---|
lpBuffer |
A pointer to a buffer that receives the computer name. This buffer must be large enough to contain the name and a terminating null character. The maximum buffer size, in characters, is |
nSize |
On input, specifies the size of the buffer pointed to by |
Return value
If the function succeeds, the return value is nonzero. The buffer pointed to by lpBuffer is filled with the computer name, and nSize is set to the number of characters copied to the buffer, not including the terminating null character.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
GetComputerNameA.
Remarks
The name returned is the name set in the registry. This name can be a Unicode string. You can use the _wsetenv_s function to set the COMPUTERNAME environment variable.
To retrieve the DNS name of the computer, call the GetComputerNameEx function with the ComputerNameDnsHostname or ComputerNameDnsFullyQualified name format.
Requirements
| Interface | Value |
|---|---|
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Header | sysinfoapi.h (include windows.h) |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |