If you want only the local computer name (NetBIOS) to use the GetComputerName . It retrieves only the name of the local computer, which is installed when the system starts, when the system reads it from the registry.
BOOL WINAPI GetComputerName( _Out_ LPTSTR lpBuffer, _Inout_ LPDWORD lpnSize );
Learn more about GetComputerName
If you want to get the DNS host name, DNS domain name, or fully qualified DNS name, call the GetComputerNameEx .
BOOL WINAPI GetComputerNameEx( _In_ COMPUTER_NAME_FORMAT NameType, _Out_ LPTSTR lpBuffer, _Inout_ LPDWORD lpnSize );
Learn more about GetComputerNameEx
Ajay gupta
source share