C

Get computer name in C – Unicode

GetComputerNameW – retrieves the NetBIOS name of the local computer for Unicode names. This name is established at system startup, when the system reads it from the registry. GetComputerNameW retrieves only the NetBIOS name of the local computer.

#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
//..
int length = MAX_COMPUTERNAME_LENGTH + 1;
WCHAR buffer[length];
if(GetComputerNameW(buffer, (LPDWORD)&length) == 0){
    printf("Error code: %ld", GetLastError());
}
else{
    buffer[length] = 0;
    wprintf(L"Computer name: %s\n", buffer);
}
//..