<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Visual C++ Tips &#187; PIP_ADAPTER_INFO</title>
	<atom:link href="http://weseetips.com/tag/pip_adapter_info/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 11 Mar 2010 09:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>How to get the MAC address of your network adapter.</title>
		<link>http://weseetips.com/2008/05/24/how-to-get-the-mac-address-of-your-network-adapter/</link>
		<comments>http://weseetips.com/2008/05/24/how-to-get-the-mac-address-of-your-network-adapter/#comments</comments>
		<pubDate>Sat, 24 May 2008 18:56:02 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Networking & Winsock]]></category>
		<category><![CDATA[GetAdaptersInfo()]]></category>
		<category><![CDATA[Iphlpapi.h]]></category>
		<category><![CDATA[Iphlpapi.lib]]></category>
		<category><![CDATA[IP_ADAPTER_INFO]]></category>
		<category><![CDATA[MAC]]></category>
		<category><![CDATA[MAC address]]></category>
		<category><![CDATA[Media Access Control address]]></category>
		<category><![CDATA[PIP_ADAPTER_INFO]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=132</guid>
		<description><![CDATA[MAC address stands for &#8220;Media Access Control&#8220; address which is 6 bytes( 48 bits ) long. MAC address is the unique address which is used to identify network interface hardware. So how to get the MAC address of your network adapter? You can use the function &#8211; GetAdaptersInfo(). The network adapter information will be populated [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
<span style="color:#0000ff;">MAC </span>address stands for <span style="color:#0000ff;">&#8220;</span><span style="color:#0000ff;">Media Access Control</span><span style="color:#0000ff;">&#8220;</span> address which is<span style="color:#0000ff;"> 6 bytes( 48 bits ) long</span>. MAC address is the unique address which is used to identify network interface hardware. So how to get the MAC address of your network adapter?</p>
<p><img class="alignnone size-medium wp-image-12" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
You can use the function &#8211; <span style="color:#0000ff;">GetAdaptersInfo()</span>. The network adapter information will be populated and filled back in <span style="color:#0000ff;">IP_ADAPTER_INFO</span> structure. In that structure, you can get the network adapter name, MAC address and a couple of other information. See the sample code snippet.</p>
<pre>#include "Iphlpapi.h"
...
// Get the buffer length required for IP_ADAPTER_INFO.
ULONG BufferLength = 0;
BYTE* pBuffer = 0;
if( ERROR_BUFFER_OVERFLOW == GetAdaptersInfo( 0, &amp;BufferLength ))
{
    // Now the BufferLength contain the required buffer length.
    // Allocate necessary buffer.
    pBuffer = new BYTE[ BufferLength ];
}
else
{
    // Error occurred. handle it accordingly.
}

// Get the Adapter Information.
PIP_ADAPTER_INFO pAdapterInfo =
      reinterpret_cast&lt;PIP_ADAPTER_INFO&gt;(pBuffer);
GetAdaptersInfo( pAdapterInfo, &amp;BufferLength );

// Iterate the network adapters and print their MAC address.
while( pAdapterInfo )
{
    // Assuming pAdapterInfo-&gt;AddressLength is 6.
    CString csMacAddress;
    csMacAddress.Format(_T("%02x:%02x:%02x:%02x:%02x:%02x"),
                        pAdapterInfo-&gt;Address[0],
                        pAdapterInfo-&gt;Address[1],
                        pAdapterInfo-&gt;Address[2],
                        pAdapterInfo-&gt;Address[3],
                        pAdapterInfo-&gt;Address[4],
                        pAdapterInfo-&gt;Address[5]);

    cout &lt;&lt; "Adapter Name :" &lt;&lt; pAdapterInfo-&gt;AdapterName &lt;&lt; " "
         &lt;&lt; "MAC :" &lt;&lt; (LPCTSTR) csMacAddress &lt;&lt; endl;

    // Get next adapter info.
    pAdapterInfo = pAdapterInfo-&gt;Next;
}

// deallocate the buffer.
delete[] pBuffer;</pre>
<p><img class="alignnone size-medium wp-image-18" src="http://weseetips.files.wordpress.com/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Don&#8217;t forget to add <span style="color:#0000ff;">Iphlpapi.lib</span> to project settings.</p>
<p><img class="alignnone size-medium wp-image-51" src="http://weseetips.files.wordpress.com/2008/03/beginnerseries.jpg?w=215" alt="" width="215" height="32" /><br />
Targeted Audience &#8211; Beginners.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/05/24/how-to-get-the-mac-address-of-your-network-adapter/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

