2.1.25.13 GetComputerName

Description

The GetComputerName function retrieves the NetBIOS name of the local computer.

Syntax

BOOL GetComputerName( LPSTR lpBuffer, DWORD * lpnSize )

Parameters

lpBuffer
[output]computer name
lpnSize
[output]On input, specifies the size of the buffer. On output, receives the number of chars copied to the buffer not including null terminator.

Return

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero.

Examples

EX1

int GetComputerName_ex1()
{
    char szComputerName[MAX_PATH];
    DWORD dwSize = MAX_PATH;
    if( GetComputerName(szComputerName, &dwSize) )
        printf("Computer Name is %s\n", szComputerName);
    else
        printf("Error calling GetComputerName\n");
    return 1;
}

Remark

See Also

GetUserName

Header to Include

origin.h

Reference