🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #5374

Re: Using SNMP to extract the MAC Address in Builder 6

#5374
From: Richard
Date: Tue, 24 Aug 2004 11:14
58 lines
2619 bytes
Many thanks Mark. Your code works perfecly on BCB6/WinXP. I
was not aware of all the great functions available in 
IPHLPAPI.lib. I definitely will not be playing with the
unbelievably complicated SNMP API again.

Richard

"Mark Jacobs" <markjattycriticaldottycodottyuk> wrote:
>On 24 Aug 2004 03:07:02 -0700, Richard <Richard.Gallois@footfall.com>  =
>
>wrote:
>
>> In the article http://bdn.borland.com/article/0,1410,26040,00.html 3  =
>
>> methods of how to obtain the MAC addresses of NICs are
>> described. The third method uses SNMP and seems to work perfectly with=
>  =
>
>> Builder 5, but I cannot get it to work with Builder 6. The
>> program compiles and runs, but does not report any NICs present.  =
>
>> Exceptions are also thrown as the routine crashes due to no NICs.
>
>AnsiString mjgetnicinfo()
>{
>   IP_ADAPTER_INFO AdapterInfo[16]; AnsiString retv=3D""; unsigned int i=
>i;  =
>
>DWORD dwBufLen,dwStatus;
>   dwBufLen=3Dsizeof(AdapterInfo);  =
>
>dwStatus=3DGetAdaptersInfo(AdapterInfo,&dwBufLen);
>   if (dwStatus!=3DERROR_SUCCESS) return "**Could not Obtain NIC Info";
>   PIP_ADAPTER_INFO pAdapterInfo=3DAdapterInfo;
>   do
>   {
>     retv+=3D"Name :"+AnsiString(pAdapterInfo->AdapterName)+"\r\nDescrip=
>tion  =
>
>:"+
>           AnsiString(pAdapterInfo->Description)+"\r\nMAC :";
>     for (ii=3D0;ii<pAdapterInfo->AddressLength;++ii)  =
>
>retv+=3DIntToHex(pAdapterInfo->Address[ii],2)+" ";
>     retv+=3D"\r\n"; pAdapterInfo=3DpAdapterInfo->Next;
>   }
>   while (pAdapterInfo);
>   return retv;
>}
>
>Does the routine above work? Hope it helps.
>-- =
>
>Mark Jacobs
>DK Computing
>http://www.dkcomputing.co.uk
>markj atty critical dotty co dotty uk
Technical Details
Message-ID: <412b2320$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <412b1346$1@newsgroups.borland.com> <opsc8fuzo1bvaws7@dk-tzx09ucg42z4.s1.sol1.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,cc9893f83af43bf4
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Richard" <Richard.Gallois@footfall.com>
Sender: "Richard" <Richard.Gallois@footfall.com>
Reply-To: "Richard" <Richard.Gallois@footfall.com>
Subject: Re: Using SNMP to extract the MAC Address in Builder 6
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 193.123.250.26     
References: <412b1346$1@newsgroups.borland.com> <opsc8fuzo1bvaws7@dk-tzx09ucg42z4.s1.sol1.co.uk>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <412b2320$1@newsgroups.borland.com>
Date: 24 Aug 2004 04:14:40 -0700
X-Trace: newsgroups.borland.com 1093346080 207.105.83.66 (24 Aug 2004 04:14:40 -0700)
Lines: 59
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail