//---------------------------------------------------------------------------
//#define _WIN32_WINNT 0x0500
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include <stdio.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Memo1->Lines->Clear();
TCHAR buffer[256] = TEXT("");
TCHAR szDescription[8][32] = {TEXT("NetBIOS"),
TEXT("DNS hostname"),
TEXT("DNS domain"),
TEXT("DNS fully-qualified"),
TEXT("Physical NetBIOS"),
TEXT("Physical DNS hostname"),
TEXT("Physical DNS domain"),
TEXT("Physical DNS fully-qualified")};
int cnf = 0;
DWORD dwSize = sizeof(buffer);
for (cnf = 0; cnf < ComputerNameMax; cnf++)
{
if(!GetComputerNameEx((COMPUTER_NAME_FORMAT)cnf, buffer, &dwSize))
{
wchar_t wcError[256];
swprintf( wcError, L"GetComputerNameEx failed (%d)", GetLastError() ) ;
ShowMessage( (String)wcError );
return;
}
else
{
wchar_t wcMemo[500];
swprintf(wcMemo, L"%s: %s", szDescription[cnf], buffer);
Memo1->Lines->Add( (String)wcMemo );
}
dwSize = sizeof(buffer);
ZeroMemory(buffer, dwSize);
}
}
//---------------------------------------------------------------------------