QHostInfo::localDomainName()
#include <sysinfoapi.h>
#include <winnls.h>
#include <QDebug>
void GET_COMPUTER_NAME_FORMAT()
{
QStringList list;
TCHAR buf[256];
unsigned long size = sizeof(buf);
QString message[8] = {
"NetBIOS",
"DnsHostname",
"DnsDomain",
"DnsFullyQualified",
"PhysicalNetBIOS",
"PhysicalDnsHostname",
"PhysicalDnsDomain",
"PhysicalDnsFullyQualified"
};
for (int i = 0; i < ComputerNameMax; ++i)
{
if (GetComputerNameEx((COMPUTER_NAME_FORMAT)i, buf, &size))
{
int i = WideCharToMultiByte(CP_ACP, 0, buf, -1, nullptr, 0, nullptr, nullptr);
char* ch = new char[i * sizeof(char)];
WideCharToMultiByte(CP_ACP, 0, buf, -1, ch, i, nullptr, nullptr);
qInfo() << message[i] << " " + QString(ch);
}
size = sizeof(buf);
memset(buf, 0, size);
}
}