<?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>சுதர்சன் சாந்தியப்பன் &#187; uuid</title>
	<atom:link href="http://sudarsun.in/blog/tag/uuid/feed/" rel="self" type="application/rss+xml" />
	<link>http://sudarsun.in/blog</link>
	<description>Dream of the Impossible™</description>
	<lastBuildDate>Sun, 20 May 2012 17:23:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Get MAC address using C++</title>
		<link>http://sudarsun.in/blog/2009/07/get-mac-address-using-c/</link>
		<comments>http://sudarsun.in/blog/2009/07/get-mac-address-using-c/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 12:18:43 +0000</pubDate>
		<dc:creator>sudarsun</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[random-numbers]]></category>
		<category><![CDATA[uuid]]></category>
		<category><![CDATA[uuidcreate]]></category>
		<category><![CDATA[UuidCreateSequential]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://sudarsun.in/blog/2009/07/get-mac-address-using-c/</guid>
		<description><![CDATA[There is a Simple way to capture the MAC address of the machine in Win32 environment. In Win32, UUID (version 1) uses MAC address &#38; timestamp as the seeds for generating the UUID.  In the UUID string, the last 6 bytes are the MAC address of the machine.  UuidCreateSequential() is the Win32 API which is [...]]]></description>
			<content:encoded><![CDATA[<p align="justify">There is a Simple way to capture the MAC address of the machine in Win32 environment. In Win32, UUID (version 1) uses MAC address &amp; timestamp as the seeds for generating the UUID.  In the UUID string, the last 6 bytes are the MAC address of the machine.  <strong><a href="http://msdn.microsoft.com/en-us/library/aa379322%28VS.85%29.aspx" target="_blank">UuidCreateSequential()</a> </strong>is the Win32 API which is used to capture the MAC address via the UUID generated by it.</p>
<pre>#include &lt;rpc.h&gt;      // for UUID, UuidCreateSequential
#include &lt;cstring&gt;    // for memcpy
#include &lt;algorithm&gt;  // for std::swap

unsigned __int64
MACAddress( void ) const
{
    UUID u;
    ::UuidCreateSequential( &amp;u );

    u.Data4[0] = u.Data4[1] = 0;

    std::swap( u.Data4[0], u.Data4[7] );
    std::swap( u.Data4[1], u.Data4[6] );
    std::swap( u.Data4[2], u.Data4[5] );
    std::swap( u.Data4[3], u.Data4[4] );

    unsigned __int64 code;
    ::memcpy( &amp;code, &amp;u.Data4, sizeof(u.Data4) );

    return code;
}   // MACAddress</pre>
<p align="justify">Let me share another hack.  If you want to generate strings which do not repeat themselves, you could use <a href="http://msdn.microsoft.com/en-us/library/aa379205%28VS.85%29.aspx" target="_blank"><strong>UuidCreate()</strong></a> Win32 API, which generates unique UUIDs everytime the function is called.  The UUID thus obtained can be converted to a number or a string depending upon the need, which guarantees non-repeatable ids.</p>
]]></content:encoded>
			<wfw:commentRss>http://sudarsun.in/blog/2009/07/get-mac-address-using-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  sudarsun.in/blog/tag/uuid/feed/ ) in 0.39747 seconds, on May 22nd, 2012 at 9:54 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 22nd, 2012 at 10:54 pm UTC -->
