Log in

View Full Version : Need A GUID In A Hurry?


Kris Kumar
10-20-2004, 06:30 PM
<div class='os_post_top_link'><a href='http://blog.opennetcf.org/pfoot/PermaLink.aspx?guid=296990fd-10ee-4c56-a9d6-d60d7716c1f6' target='_blank'>http://blog.opennetcf.org/pfoot/PermaLink.aspx?guid=296990fd-10ee-4c56-a9d6-d60d7716c1f6</a><br /><br /></div><i>"There may be times in your application you need to generate a new unique Guid. The System.Guid class in .NETCF v1.0 doesn't have the NewGuid method which is what you would normally use on the desktop. There are a couple of proposed alternatives, either <a href="http://blog.opennetcf.org/pfoot/ct.ashx?id=296990fd-10ee-4c56-a9d6-d60d7716c1f6&url=http%3a%2f%2fwww.codeproject.com%2fnetcf%2fPPCGuidGen.asp">generating one yourself by following the standards for Guids</a> - using a few P/Invokes to Crypto API methods to get random numbers, using the <a href="http://blog.opennetcf.org/pfoot/ct.ashx?id=296990fd-10ee-4c56-a9d6-d60d7716c1f6&url=http%3a%2f%2fwww.opennetcf.org%2flibrary%2fOpenNETCF.GuidExMembers.html">GuidEx class</a> which uses the same technique or indirectly using SqlCe to create a new identity value."</i><br /><br />Peter Foot in his blog has provided an easy way to generate a GUID, which involves only a single P/Invoke call to one of the COM subsystem API methods. So in case you need a GUID in a hurry, you now know where to look. :-)