Article View: borland.public.cppbuilder.nativeapi
Article #13170Re: Retrieving Address info from GetAdaptersInfo
From: Vladimir Afanasyev
Date: Thu, 23 Oct 2003 09:22
Date: Thu, 23 Oct 2003 09:22
53 lines
2252 bytes
2252 bytes
Hi,
"Maurice Anderson" <mauriceanderson@hotmail.com> wrote:
>
>I tried the ARRAYOFCONST macro and the compiler errors went away, however, I
>don't get any data when I do a:
>ShowMessage(m_macaddress);
>
Function Format RETURNS result string so you use this
function incorrectly.
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];
for(int i=1 ; i <= n; ++i)
{
if(GetAdaptersInfo(&info,&len) == ERROR_SUCCESS)
{
TVarRec v[] = {info.Address[0], info.Address[1], info.Address[2],
info.Address[3],info.Address[4],info.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:
<3f979dce$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f977b4f@newsgroups.borland.com> <3f977d1e@newsgroups.borland.com> <3f978730$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 02:40:14 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> NNTP-Posting-Host: 207.105.83.66 Message-ID: <3f979dce$1@newsgroups.borland.com> Date: 23 Oct 2003 02:22:22 -0700 X-Trace: newsgroups.borland.com 1066900942 207.105.83.66 (23 Oct 2003 02:22:22 -0700) Lines: 53 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail