Article View: borland.public.cppbuilder.nativeapi
Article #13171Re: Retrieving Address info from GetAdaptersInfo
From: Vladimir Afanasyev
Date: Thu, 23 Oct 2003 09:45
Date: Thu, 23 Oct 2003 09:45
45 lines
2291 bytes
2291 bytes
oops, I did it again.
Errors in my code must be:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
IP_ADAPTER_INFO info;
unsigned long len=0;
int n;
AnsiString m_macaddress;
if(GetAdaptersInfo(&info,&len) == ERROR_BUFFER_OVERFLOW)
n=len/sizeof(info);
else
{
ShowMessage("No data or another error");
Application->Terminate();
return;
}
if(n <= 0)
{
ShowMessage("Something bad !!!");
Application->Terminate();
return;
}
PIP_ADAPTER_INFO pinfox=new IP_ADAPTER_INFO[n];
if(GetAdaptersInfo(pinfox,&len) == ERROR_SUCCESS)
for(int i=0 ; i < n; ++i)
{
TVarRec v[] = {pinfox[i].Address[0], pinfox[i].Address[1], pinfox[i].Address[2],
pinfox[i].Address[3],pinfox[i].Address[4],pinfox[i].Address[5]};
m_macaddress=Format("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",v,5);
ShowMessage("Adapter num. "+IntToStr(i)+ "\n MAC address "+m_macaddress);
}
else ShowMessage("Error !!!");
delete [] pinfox;
}
Vladimir.
Technical Details
Message-ID:
<3f97a357$2@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!news-xfer.cox.net!peer02.cox.net!peer01.cox.net!cox.net!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3f977b4f@newsgroups.borland.com> <3f977d1e@newsgroups.borland.com> <3f978730$1@newsgroups.borland.com> <3f979dce$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,90790ba1c056df66 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-10-23 03:04:31 PST From: "Vladimir Afanasyev" <avv@systema.kiev.ua> Sender: "Vladimir Afanasyev" <avv@systema.kiev.ua> Reply-To: "Vladimir Afanasyev" <avv@systema.kiev.ua> Subject: Re: Retrieving Address info from GetAdaptersInfo Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 212.82.216.226 X-Forwarded-For: 192.168.0.147 References: <3f977b4f@newsgroups.borland.com> <3f977d1e@newsgroups.borland.com> <3f978730$1@newsgroups.borland.com> <3f979dce$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <3f97a357$2@newsgroups.borland.com> Date: 23 Oct 2003 02:45:59 -0700 X-Trace: newsgroups.borland.com 1066902359 207.105.83.66 (23 Oct 2003 02:45:59 -0700) Lines: 45 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!news-xfer.cox.net!peer02.cox.net!peer01.cox.net!cox.net!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail