Article View: borland.public.cppbuilder.internet.socket
Article #5372Re: Using SNMP to extract the MAC Address in Builder 6
From: Mark Jacobs
Date: Tue, 24 Aug 2004 10:38
Date: Tue, 24 Aug 2004 10:38
49 lines
2413 bytes
2413 bytes
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=""; unsigned int ii;
DWORD dwBufLen,dwStatus;
dwBufLen=sizeof(AdapterInfo);
dwStatus=GetAdaptersInfo(AdapterInfo,&dwBufLen);
if (dwStatus!=ERROR_SUCCESS) return "**Could not Obtain NIC Info";
PIP_ADAPTER_INFO pAdapterInfo=AdapterInfo;
do
{
retv+="Name :"+AnsiString(pAdapterInfo->AdapterName)+"\r\nDescription
:"+
AnsiString(pAdapterInfo->Description)+"\r\nMAC :";
for (ii=0;ii<pAdapterInfo->AddressLength;++ii)
retv+=IntToHex(pAdapterInfo->Address[ii],2)+" ";
retv+="\r\n"; pAdapterInfo=pAdapterInfo->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:
<opsc8fuzo1bvaws7@dk-tzx09ucg42z4.s1.sol1.co.uk>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<412b1346$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,cc9893f83af43bf4 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: Using SNMP to extract the MAC Address in Builder 6 Reply-To: markjattycriticaldottycodottyuk References: <412b1346$1@newsgroups.borland.com> Message-ID: <opsc8fuzo1bvaws7@dk-tzx09ucg42z4.s1.sol1.co.uk> From: "Mark Jacobs" <markjattycriticaldottycodottyuk> Organization: DK Computing Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable Date: Tue, 24 Aug 2004 11:38:49 +0100 User-Agent: Opera M2/7.53 (Win32, build 3850) NNTP-Posting-Host: 81.144.157.8 X-Trace: newsgroups.borland.com 1093343928 81.144.157.8 (24 Aug 2004 03:38:48 -0700) Lines: 49 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail