<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Jeremy Hance</title><link>http://blogs.msdn.com/jehance/default.aspx</link><description>CF GAC, Loader, Interop, etc...</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Back from the Dead</title><link>http://blogs.msdn.com/jehance/archive/2005/07/01/434725.aspx</link><pubDate>Fri, 01 Jul 2005 21:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:434725</guid><dc:creator>jehance</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jehance/comments/434725.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jehance/commentrss.aspx?PostID=434725</wfw:commentRss><description>&lt;P&gt;I knew it'd been a while since I'd updated my blog, but the realization that it'd had been nearly a year since my last post shocked me some.&amp;nbsp; I mean, I've told people it'd been nearly a year, but didn't really believe it until I saw the date myself.&amp;nbsp; Well, it's time to rectify that problem and re-emerge onto the blogging scene.&lt;/P&gt;
&lt;P&gt;I've been working on a project over the last several months called "Play".&amp;nbsp; Those of you who attended MEDC 2005 or Gamefest 2005 may have seen demos built on Play.&amp;nbsp; It's a Peer to Peer Gaming Infrastructure, written on the Compact Framework, which allows for pluggable games and transports.&amp;nbsp; It maintains your buddy lists and lets you play multiple games (both 2D Winforms Games and Managed Direct3D Mobile games).&amp;nbsp; A lot of interesting things have come out of the Play work, and I plan to start blogging regularly both on Play, and another project of mine (Aquarium.NET) which you may have seen at MEDC 2004 or PDC 2003.&lt;/P&gt;
&lt;P&gt;So, without further adieu, my first blog post from Play is a simple ResourceHelper class (&lt;a href="http://blogs.msdn.com/jehance/archive/2005/07/01/434716.aspx"&gt;http://blogs.msdn.com/jehance/archive/2005/07/01/434716.aspx&lt;/A&gt;).&amp;nbsp; Retrieving resources can be a pain on CF, so I developed this class in Play to make things a little easier.&amp;nbsp; It scans the resources from the calling assembly and will find case insensitive full and partial matches, and can&amp;nbsp;even return both streams and byte arrays.&lt;/P&gt;
&lt;P&gt;My next post will be for playing sound, so stay tuned.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=434725" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jehance/archive/tags/FAQs/default.aspx">FAQs</category></item><item><title>A Simple Resource Helper Class</title><link>http://blogs.msdn.com/jehance/archive/2005/07/01/434716.aspx</link><pubDate>Fri, 01 Jul 2005 21:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:434716</guid><dc:creator>jehance</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/jehance/comments/434716.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jehance/commentrss.aspx?PostID=434716</wfw:commentRss><description>&lt;FONT color=#0000ff&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;using&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; System;&lt;BR&gt;&lt;FONT color=#0000ff&gt;using&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; System.Reflection;&lt;BR&gt;&lt;FONT color=#0000ff&gt;using&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; System.IO;&lt;BR&gt;&lt;FONT color=#0000ff&gt;using&lt;/FONT&gt; System.Runtime.CompilerServices;&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;///&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#008000 size=2&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" color=#808080 size=2&gt;&amp;lt;summary&amp;gt;&lt;BR&gt;///&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#008000&gt; A simple helper class for extracting Resources from the &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#008000&gt; calling assembly&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/summary&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;FONT color=#0000ff&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; ResourceHelper&lt;BR&gt;{&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; Stream GetStream(Assembly assembly, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; ResourceName)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt; (ResourceName != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt; &amp;amp;&amp;amp; ResourceName.Trim() != &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;.Empty)&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ResourceName = ResourceName.Trim();&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; name &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; assembly.GetManifestResourceNames())&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt;.Compare(ResourceName, name, &lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;) == 0)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; assembly.GetManifestResourceStream(name);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ResourceName = ResourceName.ToUpper();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;foreach&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; name &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; assembly.GetManifestResourceNames())&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; (name.ToUpper().IndexOf(ResourceName) &amp;gt;= 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; assembly.GetManifestResourceStream(name);&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; MemoryStream(&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;byte&lt;/FONT&gt;[0], &lt;FONT color=#0000ff&gt;false&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;);&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;summary&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; Returns the requested resource as a Stream&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/summary&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;param name="ResourceName"&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; The name of the resource to retrieve&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/param&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;returns&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; A stream for the requested resource on success.&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; An empty stream on failure&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/returns&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;remarks&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; GetStream first searches for an exact, case insensitive&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; match to ResourceName. If the initial search fails,|&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/// G&lt;/FONT&gt;&lt;FONT color=#008000&gt;etStream will search again and return the first&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; resource for which ResourceName is a case insensitive&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; sub-string&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;[MethodImpl(MethodImplOptions.NoInlining)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; Stream GetStream(&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; ResourceName)&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New" color=#0000ff&gt;return&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; GetStream(Assembly.GetCallingAssembly(), ResourceName);&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;summary&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; Returns the requested resource as a byte[]&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/summary&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;param name="ResourceName"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; The name of the resource to retrieve&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/param&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;returns&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; A byte[] for the requested resource on success.&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; An empty byte[] on failure&lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/returns&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;remarks&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; GetBytes first searches for an exact, case insensitive&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; match to ResourceName. If the initial search fails,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; GetBytes will search again and return the first&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; resource for which ResourceName is a case insensitive&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; sub-string&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;[MethodImpl(MethodImplOptions.NoInlining)]&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;byte&lt;/FONT&gt;[] GetBytes(&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; ResourceName)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;Stream s = GetStream(Assembly.GetCallingAssembly(), ResourceName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;byte&lt;/FONT&gt;[] bytes = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;byte&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;[s.Length];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;s.Read(bytes, 0, bytes.Length);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;s.Close();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New" color=#0000ff&gt;return&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; bytes;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;--- jeh&lt;BR&gt;This post is provided “As Is”, with no warranties, and confers no rights.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=434716" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jehance/archive/tags/Samples+_2F00_+Snippets/default.aspx">Samples / Snippets</category></item><item><title>PocketOutlook and COM Interop</title><link>http://blogs.msdn.com/jehance/archive/2004/08/12/213835.aspx</link><pubDate>Thu, 12 Aug 2004 23:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:213835</guid><dc:creator>jehance</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jehance/comments/213835.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jehance/commentrss.aspx?PostID=213835</wfw:commentRss><description>&lt;p&gt;New to the&amp;nbsp;.NET Compact Framework in Whidbey Beta 1 is a feature known as COM Interop.&amp;nbsp; Among other things, this feature allows simple managed access to a number of Native APIs, including the Pocket Outlook Object Model (POOM).&amp;nbsp; &lt;A href="http://blogs.msdn.com/stevenpr"&gt;Steven&lt;/a&gt; has posted a great article on getting POOM into your Whidbey project (I highly recommend reading it &lt;A href="http://blogs.msdn.com/stevenpr/archive/2004/08/05/209390.aspx"&gt;here&lt;/a&gt;.)&lt;/p&gt; &lt;p&gt;I thought I'd take some time to focus on Step 4 of Steven's article, "Write your POOM application".&amp;nbsp; After all, once you've gotten the PocketOutlook Interop Assembly references, it's time to do something with it.&lt;/p&gt; &lt;p&gt;Two resources I've found to be invaluable are the &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcepoom/html/ceoriPocketOutlookObjectModel.asp"&gt;Pocket Outlook Object Model Documentation&lt;/a&gt;&amp;nbsp;at MSDN, and the Object Browser within Whidbey itself.&amp;nbsp; &lt;/p&gt;&lt;img src="http://jehance.members.winisp.net/images/TaskViewerProject1.jpg" /&gt; &lt;p&gt;If you're not familiar with the Object Browser, take some time to get acquainted with it once you've referenced the Pocket Outlook Interop Assembly.&amp;nbsp; All assemblies and their namespaces are listed in the browser.&lt;/p&gt; &lt;p&gt;&lt;img src="http://jehance.members.winisp.net/images/TaskViewerProject2.jpg" /&gt;&lt;/p&gt; &lt;p&gt;By expanding the namespace, you can look at individual classes and interfaces, and see not only their methods, by also the signatures as they have been imported by TLBIMP.&amp;nbsp; And, of course, through the magic that is intellisense, you get full intellisense for the POOM classes and methods.&lt;/p&gt; &lt;p&gt;&lt;img src="http://jehance.members.winisp.net/images/TaskViewer5.jpg" align="left" /&gt;For my application, I chose to write a simple managed Task Viewer.&amp;nbsp; One drawback of the task viewer that ships with Windows Mobile is that there's no way to both view and edit tasks at the same time.&amp;nbsp; &lt;/p&gt; &lt;p&gt;With approximately 2 hours of coding, I was able to produce the application pictured to the left.&amp;nbsp; The ListView shows all the tasks on the system (the same tasks that will show in the task viewer that ships with Windows Mobile).&amp;nbsp;The fields at the bottom&amp;nbsp;will allow the user to add new tasks, or edit existing tasks after selecting them in the ListView.&amp;nbsp; Using the context menu on the ListView, the user can mark tasks as complete (which highlights them with a dark grey), or delete them.&lt;/p&gt; &lt;p&gt;Changes made to the tasks via this application are reflected in the task viewer integrated into Windows Mobile.&amp;nbsp; The app stores no information internally, but rather makes all updates, and retrieves all displayed items, directly with POOM.&lt;/p&gt; &lt;p&gt;The code for this program (not counting that code automatically generated by the Windows Designer) is well under 300 lines (including white space for readability), and as you can well imagine, the majority of the code I wrote manipulates the UI.&amp;nbsp; Less than 40 lines of C# code were required to manipulate POOM in the ways I've described.&amp;nbsp; &lt;/p&gt; &lt;p&gt;The code required to activate the POOM Application object, logon, and retrieve the the Task Folder is as simple as:&lt;/p&gt; &lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt; &lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;// Get the application class and the tasksFolder&lt;/font&gt;&lt;br /&gt;ApplicationClass outlookApp = &lt;font color="#0000ff"&gt;new&lt;/font&gt; ApplicationClass();&lt;br /&gt;outlookApp.Logon(0);&lt;br /&gt;IFolder tasksFolder = outlookApp.GetDefaultFolder(OlDefaultFolders.olFolderTasks);&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p dir="ltr"&gt;You can find TaskViewer.cs &lt;a href="http://jehance.members.winisp.net/files/TaskViewer.cs.htm"&gt;here&lt;/a&gt;.&amp;nbsp; Please feel free to send me any questions regarding this application, or using COM Interop with POOM.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=213835" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jehance/archive/tags/Samples+_2F00_+Snippets/default.aspx">Samples / Snippets</category></item><item><title>Space Exploration (Way Off Topic)</title><link>http://blogs.msdn.com/jehance/archive/2004/07/20/188873.aspx</link><pubDate>Tue, 20 Jul 2004 17:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:188873</guid><dc:creator>jehance</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/jehance/comments/188873.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jehance/commentrss.aspx?PostID=188873</wfw:commentRss><description>&lt;P&gt;It is my intention to keep this blog parimarily technical, but I feel the need to make an off topic post today.&lt;/P&gt;
&lt;P&gt;For those that do not know, today is the 35th Anniversary of Neil Armstrong's famous first step out onto the moon, one of a few truly monumental events in the history of our world.&amp;nbsp; If you turn on the TV or listen to the radio today, you're certain to hear at least some snippet about the anniversary, as well you should.&lt;/P&gt;
&lt;P&gt;I've known about the upcoming anniversary for days, but I was reminded in the car this morning while driving my step-daughter to the airport.&amp;nbsp; I was again reminded while watching the news at the airport (during the inevitable delay before boarding).&amp;nbsp; I was amazed, and frankly somewhat dismayed, when the CNN Anchor asked people to email in to discuss whether or not we should continue to push to the moon and, possibly, beyond.&lt;/P&gt;
&lt;P&gt;And, I must admit, I was quite shocked to see the numbers of people that responded crying an emphatic &amp;#8220;no&amp;#8221;, citing cost, risk, technology, and 'lack of need' as the barriers to our continued push into this vast frontier.&lt;/P&gt;
&lt;P&gt;There are certainly numerous 'reasons' to continue our efforts to push into space:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The human race continues to grow, with no end in sight.&amp;nbsp; With our growth, we expand, and push into those areas that were once our farm lands and our ranches, our wild territory that belongs to the other inhabitants of our planet.&amp;nbsp; Our need for room to live will eventually overwhelm our tiny planet, stifle, and kill it, unless we find other places which can support us and those things we need.&lt;/LI&gt;
&lt;LI&gt;As we grow, we consume natural resources at ever greater rates.&amp;nbsp; Even our renewable resources need space in which to renew, and we consume that space.&amp;nbsp; We must eventually find new wealth springs of these resources, or at the very least room in which these resources may renew.&lt;/LI&gt;
&lt;LI&gt;The discoveries and technologies that have come both directly and indirectly from our push into the unknown reaches of space are many, and significant.&amp;nbsp; Not an aspect of our lives is untouched by these technologies, materials&amp;nbsp;and gadgets, and very few of us can honestly claim we don't consider these advancements fundamental to our way of life... and we have only scratched the surface.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;And, yet, the most compelling argument to continue our drive into unknown space is one beyond reason and logic; it is at the very core of what makes us human; it is, quite simply, &amp;#8220;because it's there.&amp;#8221;&lt;/P&gt;
&lt;P&gt;Why do we celebrate Neil Armstrong's titanic first steps onto a new world?&amp;nbsp; Why is he considered a true hero?&amp;nbsp; Why was it a &amp;#8220;giant leap for mankind&amp;#8221;?&amp;nbsp; The cost of those steps was enourmous, the risks extreme, the technology insufficient, and the need small.&amp;nbsp; Why, then, are men such as he - the Columbus's, the Lewis and Clark's, and the Magellan's of the world, so celebrated, so revered, so well remembered, that their stories are told&amp;nbsp;even centuries after their accomplishments.&lt;/P&gt;
&lt;P&gt;Why do small boys and girls dream of one day being astronauts, being the first to step upon the surface of a strange new world?&lt;/P&gt;
&lt;P&gt;It is because facing the risks, paying the costs, and looking fear in the eye to discover the unknown&amp;nbsp;are at the very heart of what makes us human... they are what define the human spirit... they are what set us apart from the other animals that share our home.&amp;nbsp; It is these singular men and women that give us hope and fuel our dreams.&amp;nbsp; It is these people that prove we haven't given up, that life is something which, even in the darkest hour, is still worth fighting for.&lt;/P&gt;
&lt;P&gt;I, for one, support our exploration of space whole heartedly, and support those men and women that give me, and future generations, a reason to dream..&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=188873" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jehance/archive/tags/The+Rest/default.aspx">The Rest</category></item><item><title>Working from Home</title><link>http://blogs.msdn.com/jehance/archive/2004/07/14/183569.aspx</link><pubDate>Wed, 14 Jul 2004 23:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:183569</guid><dc:creator>jehance</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/jehance/comments/183569.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jehance/commentrss.aspx?PostID=183569</wfw:commentRss><description>&lt;P&gt;Is there anything better than working from home?&lt;/P&gt;
&lt;P&gt;I'm sitting on my back porch today, wireless laptop at the ready, 10 month old Chocolate Lab at my feet, staring out at the beautiful rarity known as a &amp;#8220;Sunny Seattle Day&amp;#8221;.&amp;nbsp; Today, it was my step-daughter's doctor appointment that prompted the day at home.&amp;nbsp; Tomorrow it will be the garage door repairmen.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not that I don't work when I stay home.&amp;nbsp; I actually got quite a bit of important work done today.&amp;nbsp; There's just something rejuvenating about a relaxing day on the back porch, with the dog, staring out at the blue between the coding and the emails.&lt;/P&gt;
&lt;P&gt;It recharges the batteries in a way that a hectic weekend just can't touch.&lt;/P&gt;
&lt;P&gt;But then, I'm weird like that.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=183569" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jehance/archive/tags/The+Rest/default.aspx">The Rest</category></item><item><title>How do I get the "right" Device ID?</title><link>http://blogs.msdn.com/jehance/archive/2004/07/12/181116.aspx</link><pubDate>Mon, 12 Jul 2004 22:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:181116</guid><dc:creator>jehance</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/jehance/comments/181116.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jehance/commentrss.aspx?PostID=181116</wfw:commentRss><description>&lt;P&gt;I've been asked more than once how to go about getting the &amp;#8220;right&amp;#8221; Device ID from managed code.&amp;nbsp; There's a myth floating around (to which, for a short time, I myself subscribed) that a device has multiple Device IDs, or that there's some trick to getting the one &amp;#8220;true&amp;#8221; Device ID.&lt;/P&gt;
&lt;P&gt;Getting the device ID isn't particularly difficult.&amp;nbsp; There are a number of samples floating around for retrieving the ID from native and managed code (my own modest offering can be found &lt;A href="http://blogs.msdn.com/jehance/archive/2004/07/12/181067.aspx"&gt;here&lt;/A&gt;).&amp;nbsp; And, believe it or not, there is only one ID, and really only one way to get at it.&amp;nbsp; Why then all the confusion?&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Windows CE specifies that a Device ID is a 2 part critter, where one part is the Platform ID, and the other part is the Preset ID.&amp;nbsp; The Platform ID is suppose to be&amp;nbsp;an identifier that uniquely identifies the type of hardware the device is running on.&amp;nbsp; So, two identical devices should have the same Platform ID.&lt;/P&gt;
&lt;P&gt;The Preset ID is suppose to be a number that uniquely identifies a specific unit of a given platform.&amp;nbsp; So, 2 identical ACME PDAs should have the same Platform ID, but different Preset IDs.&amp;nbsp; Two unrelated CE Devices might have (unlikely though it may be) the same Preset IDs, but certainly should not have the same Platform IDs.&lt;/P&gt;
&lt;P&gt;On Windows CE, the Platform ID and Preset ID can be any length.&amp;nbsp; The Pocket PC standards say that the 2 IDs together will have a length of 16 bytes, so that the DeviceID can be treated as a Guid.&amp;nbsp; So, let's talk about the Gotchas.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Gotcha #1&lt;/STRONG&gt;&lt;BR&gt;&lt;/U&gt;Often times, when someone attempts to retrieve the DeviceID, they only pay attention to either the Platform ID or the Preset ID.&amp;nbsp; However, neither ID is, by itself, unique.&amp;nbsp; It's only the combination of IDs that is guaranteed to be unique.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Gotcha #2&lt;BR&gt;&lt;/U&gt;&lt;/STRONG&gt;Alright, the DeviceID has a length of 16 bytes on PPC, so it can be treated as&amp;nbsp;a GUID.&amp;nbsp; However, there are a number of differing definitions that describe exactly what is inside&amp;nbsp;a GUID.&amp;nbsp; Three common definitions are:&lt;/P&gt;
&lt;OL dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;OL&gt;
&lt;LI&gt;byte[16]; 
&lt;LI&gt;int a;&lt;BR&gt;short b;&lt;BR&gt;short c;&lt;BR&gt;byte[8] d; 
&lt;LI&gt;DWORD a;&lt;BR&gt;DWORD b;&lt;BR&gt;DWORD c;&lt;BR&gt;DWORD d;&lt;/LI&gt;&lt;/OL&gt;&lt;/OL&gt;
&lt;P dir=ltr&gt;All of these pseudo-code definitions are 16 bytes.&amp;nbsp; However, the same data will not necessary be represented the same way in all 3 cases.&amp;nbsp; It just so happens that most platforms are Little-Endian, storing the lowest order byte before the higher order bytes.&amp;nbsp; What does that mean?&amp;nbsp; Well, a DWORD with the value of 1000 (0x00000E38) will actually be stored in memory as 0x38, 0x0E, 0x00, 0x00.&amp;nbsp; Therefore, someone who treats the 4-byte DWORD as a DWORD may get one sequence of bytes whereas someone treating it as a byte[] may get a different sequence of bytes.&lt;/P&gt;
&lt;P dir=ltr&gt;As a real world example, I used 2 different utilities to get the Device ID from my iPaq 3760, and got the following results:&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;STRONG&gt;Utility 1:&lt;/STRONG&gt; FE0CEA0D-000C-0116-0800-57454D325750&lt;BR&gt;&lt;STRONG&gt;Utility 2:&lt;/STRONG&gt; FE0CEA0D-0116-000C-4557-00085057324D&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;You may notice, if you're the kind of person that likes to rearrange things (and, gee, who isn't?) that Utility 2 gives a DeviceID that is simply a jumble of the ID given by Utility 1.&lt;/P&gt;
&lt;P dir=ltr&gt;&lt;STRONG&gt;&lt;U&gt;Gotcha #3&lt;/U&gt;&lt;/STRONG&gt;&lt;BR&gt;Some older PPC devices have a slightly different behavior when it comes to retrieving the ID.&amp;nbsp; The method we all know and love for retrieving the ID (KernelIoControl, IOCTL_HAL_GET_DEVICEID, DEVICE_ID Structure, mutter magic incantation) doesn't work the same on some older devices.&lt;/P&gt;
&lt;P dir=ltr&gt;Typically you create a DEVICE_ID structure, which is actually just a large buffer which we pretend is a structure, set its first field to its size, and pass it and its size in to KernelIoControl.&amp;nbsp; Most of the time &amp;#8220;viola&amp;#8221;, you get a DeviceID (or the Kernel says it needs a bigger buffer).&lt;/P&gt;
&lt;P dir=ltr&gt;Unfortunately, the mechanism is broken on some older devices.&amp;nbsp; In fact, on these older devices, if you claim the size of the buffer is anything other than 16 bytes (the size of a GUID), the method fails and gives you nothing.&amp;nbsp; Do not despair!&amp;nbsp; Passing in 16 as the size of the buffer will return you the entire 16 byte Device ID in the buffer, which you can then use as returned.&lt;/P&gt;
&lt;P dir=ltr&gt;&lt;STRONG&gt;&lt;U&gt;Gotcha #4&lt;/U&gt;&lt;/STRONG&gt;&lt;BR&gt;Finally, there is the matter of emulators.&amp;nbsp; Device IDs are one of those things that Windows CE specifies how it should work, and then it's up to the manufacturer of the device to actually implement.&amp;nbsp; So, of course, it's not always available as you would like.&amp;nbsp; In particular, a number of device emulators don't support any form of Device ID retrieval.&amp;nbsp;&lt;/P&gt;
&lt;P dir=ltr&gt;--- jeh&lt;BR&gt;This post is provided &amp;#8220;As Is&amp;#8221;, with no warranties, and confers no rights.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=181116" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jehance/archive/tags/FAQs/default.aspx">FAQs</category></item><item><title>A Simple Device ID Class</title><link>http://blogs.msdn.com/jehance/archive/2004/07/12/181067.aspx</link><pubDate>Mon, 12 Jul 2004 21:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:181067</guid><dc:creator>jehance</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/jehance/comments/181067.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jehance/commentrss.aspx?PostID=181067</wfw:commentRss><description>&lt;P&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;&lt;FONT color=#000000&gt;I've received a number of questions regarding how best to retrieve the Device ID.&amp;nbsp; As&amp;nbsp;a result, I've decided to provide the following class for your coding pleasure:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;&lt;FONT color=#000000&gt;--- jeh&lt;BR&gt;This posting is provided &amp;#8220;AS IS&amp;#8220;, without warranties, and confers no rights.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;
&lt;HR id=null&gt;
&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;using&lt;/SPAN&gt;&lt;SPAN&gt; System;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;using&lt;/SPAN&gt;&lt;SPAN&gt; System.Runtime.InteropServices;&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;namespace&lt;/SPAN&gt;&lt;SPAN&gt; DeviceID&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;sealed&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;class&lt;/SPAN&gt;&lt;SPAN&gt; DeviceIDException : Exception&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; DeviceIDException() : &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;base&lt;/SPAN&gt;&lt;SPAN&gt;() {}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; DeviceIDException(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;string&lt;/SPAN&gt;&lt;SPAN&gt; message) : &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;base&lt;/SPAN&gt;&lt;SPAN&gt;(message) {}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; DeviceIDException(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;string&lt;/SPAN&gt;&lt;SPAN&gt; message, Exception innerException) : &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;base&lt;/SPAN&gt;&lt;SPAN&gt;(message, innerException) {}&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #808080; FONT-FAMILY: Courier New"&gt;/// &amp;lt;summary&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #808080; FONT-FAMILY: Courier New"&gt;/// Summary description for DeviceID.&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #808080; FONT-FAMILY: Courier New"&gt;/// &amp;lt;/summary&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;sealed&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;class&lt;/SPAN&gt;&lt;SPAN&gt; DeviceID&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;private&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&lt;/SPAN&gt;&lt;SPAN&gt; GuidLength = 16;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;private&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; Int32 ERROR_NOT_SUPPORTED = 0x32;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;private&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; Int32 ERROR_INSUFFICIENT_BUFFER = 0x7A;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;private&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; Int32 IOCTL_HAL_GET_DEVICEID = 0x01010054;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;private&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[] idBytes&amp;nbsp; = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;null&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;private&lt;/SPAN&gt;&lt;SPAN&gt; Guid&amp;nbsp;&amp;nbsp; idGuid&amp;nbsp;&amp;nbsp; = Guid.Empty;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;private&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;string&lt;/SPAN&gt;&lt;SPAN&gt; idString = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;String&lt;/SPAN&gt;&lt;SPAN&gt;.Empty;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; DeviceID()&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[] buffer = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[20];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;bool&lt;/SPAN&gt;&lt;SPAN&gt; idLoaded = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;uint&lt;/SPAN&gt;&lt;SPAN&gt; bytesReturned;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;while&lt;/SPAN&gt;&lt;SPAN&gt;(!idLoaded)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Array.Copy(BitConverter.GetBytes(buffer.Length), 0, buffer, 0, 4);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;try&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idLoaded = KernelIoControl(IOCTL_HAL_GET_DEVICEID, 0, 0, buffer, (&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;uint&lt;/SPAN&gt;&lt;SPAN&gt;)buffer.Length, &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;out&lt;/SPAN&gt;&lt;SPAN&gt; bytesReturned);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;catch&lt;/SPAN&gt;&lt;SPAN&gt; (Exception e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;throw&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; DeviceIDException(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;"This platform may not support DeviceIDs"&lt;/SPAN&gt;&lt;SPAN&gt;, e);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(!idLoaded)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&lt;/SPAN&gt;&lt;SPAN&gt; error = Marshal.GetLastWin32Error();&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(error == ERROR_INSUFFICIENT_BUFFER)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;buffer = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[BitConverter.ToUInt32(buffer, 0)];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;else&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #008000; FONT-FAMILY: Courier New"&gt;// Some older PPC devices only return the ID if the buffer&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #008000; FONT-FAMILY: Courier New"&gt;// is exactly the size of a GUID, so attempt to retrieve&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #008000; FONT-FAMILY: Courier New"&gt;// the ID this way before throwing an exception&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;buffer = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[GuidLength];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idLoaded = KernelIoControl(IOCTL_HAL_GET_DEVICEID, 0, 0, buffer, GuidLength, &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;out&lt;/SPAN&gt;&lt;SPAN&gt; bytesReturned);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(idLoaded)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeFromBytes(buffer);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;else&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(error == ERROR_NOT_SUPPORTED)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;throw&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; DeviceIDException(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;"This platform does not support DeviceIDs"&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;else&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;throw&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; DeviceIDException(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;String&lt;/SPAN&gt;&lt;SPAN&gt;.Format(&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;"Error Encountered Retrieving ID (0x{0})"&lt;/SPAN&gt;&lt;SPAN&gt;, error.ToString(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;"X8"&lt;/SPAN&gt;&lt;SPAN&gt;)));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&lt;/SPAN&gt;&lt;SPAN&gt; dwPresetIDOffset = BitConverter.ToInt32(buffer, 4);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&lt;/SPAN&gt;&lt;SPAN&gt; dwPresetIDBytes = BitConverter.ToInt32(buffer, 8);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&lt;/SPAN&gt;&lt;SPAN&gt; dwPlatformIDOffset = BitConverter.ToInt32(buffer, 12);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&lt;/SPAN&gt;&lt;SPAN&gt; dwPlatformIDBytes = BitConverter.ToInt32(buffer, 16);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;idBytes = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[dwPresetIDBytes + dwPlatformIDBytes];&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Array.Copy(buffer, dwPresetIDOffset, idBytes, 0, dwPresetIDBytes);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Array.Copy(buffer, dwPlatformIDOffset, idBytes, dwPresetIDBytes, dwPlatformIDBytes);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; DeviceID(Guid g)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;idBytes = g.ToByteArray();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;idGuid = g;&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; DeviceID(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[] bytes)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeFromBytes(bytes);&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;private&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;void&lt;/SPAN&gt;&lt;SPAN&gt; InitializeFromBytes(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[] bytes)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;idBytes = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[bytes.Length];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Array.Copy(bytes, 0, idBytes, 0, bytes.Length);&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #808080; FONT-FAMILY: Courier New"&gt;/// &amp;lt;summary&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #808080; FONT-FAMILY: Courier New"&gt;/// DeviceIDs are only guaranteed to be Guids on PPC.&amp;nbsp; On generic Windows CE, they can be&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #808080; FONT-FAMILY: Courier New"&gt;/// any unspecified length&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #808080; FONT-FAMILY: Courier New"&gt;/// &amp;lt;/summary&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;bool&lt;/SPAN&gt;&lt;SPAN&gt; IsGuid&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; (idBytes.Length == GuidLength);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; Guid Guid&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(IsGuid)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(idGuid == Guid.Empty)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idGuid = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; Guid(idBytes);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; idGuid;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;else&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;throw&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; DeviceIDException(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;String&lt;/SPAN&gt;&lt;SPAN&gt;.Format(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;"The DeviceID {0} is not a Guid"&lt;/SPAN&gt;&lt;SPAN&gt;, ToString()));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;override&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;bool&lt;/SPAN&gt;&lt;SPAN&gt; Equals(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;object&lt;/SPAN&gt;&lt;SPAN&gt; obj)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(obj &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;is&lt;/SPAN&gt;&lt;SPAN&gt; DeviceID)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DeviceID rhs = (DeviceID)obj;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(idBytes.Length == rhs.idBytes.Length)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;for&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&lt;/SPAN&gt;&lt;SPAN&gt; i = 0; i &amp;lt; idBytes.Length; i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(idBytes[i] != rhs.idBytes[i])&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;override&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&lt;/SPAN&gt;&lt;SPAN&gt; GetHashCode()&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(IsGuid)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.Guid.GetHashCode();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;else&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #008000; FONT-FAMILY: Courier New"&gt;// The default GetHashCode for object is guaranteed to&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #008000; FONT-FAMILY: Courier New"&gt;// always be the same for a given object, but not for&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #008000; FONT-FAMILY: Courier New"&gt;// multiple objects with the same value.&amp;nbsp; We want a HashCode&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #008000; FONT-FAMILY: Courier New"&gt;// that will always be the same for a given ID&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[] tempbytes = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[16];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(idBytes.Length &amp;gt; 16)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Array.Copy(idBytes, 0, tempbytes, 0, 16);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;else&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Array.Clear(tempbytes, 0, 16); &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #008000; FONT-FAMILY: Courier New"&gt;// Should be unneccessary&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Array.Copy(idBytes, 0, tempbytes, 0, idBytes.Length);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; Guid(tempbytes)).GetHashCode();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;override&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;string&lt;/SPAN&gt;&lt;SPAN&gt; ToString()&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(idString == &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;String&lt;/SPAN&gt;&lt;SPAN&gt;.Empty)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(IsGuid)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idString = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.Guid.ToString();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;else&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idString = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;for&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&lt;/SPAN&gt;&lt;SPAN&gt; i = 0; i &amp;lt; idBytes.Length; i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(i == 4 || i == 6 || i == 8 || i == 10)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idString = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;String&lt;/SPAN&gt;&lt;SPAN&gt;.Format(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;"{0}-{1}"&lt;/SPAN&gt;&lt;SPAN&gt;, idString, idBytes[i].ToString(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;"x2"&lt;/SPAN&gt;&lt;SPAN&gt;));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;else&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idString = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;String&lt;/SPAN&gt;&lt;SPAN&gt;.Format(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;"{0}{1}"&lt;/SPAN&gt;&lt;SPAN&gt;, idString, idBytes[i].ToString(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;"x2"&lt;/SPAN&gt;&lt;SPAN&gt;));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; idString;&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;public&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[] ToByteArray()&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[] cpyBytes = &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[idBytes.Length];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Array.Copy(idBytes, 0, cpyBytes, 0, idBytes.Length);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; cpyBytes;&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;[DllImport(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #ff0000; FONT-FAMILY: Courier New"&gt;"coredll.dll"&lt;/SPAN&gt;&lt;SPAN&gt;, SetLastError=&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;)]&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;private&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;static&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;extern&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;bool&lt;/SPAN&gt;&lt;SPAN&gt; KernelIoControl(&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;uint&lt;/SPAN&gt;&lt;SPAN&gt; dwIoControlCode,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;uint&lt;/SPAN&gt;&lt;SPAN&gt; lpInBuf &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #008000; FONT-FAMILY: Courier New"&gt;/* set to 0 */&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;uint&lt;/SPAN&gt;&lt;SPAN&gt; nInBufSize &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #008000; FONT-FAMILY: Courier New"&gt;/* set to 0 */&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;In&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;Out&lt;/SPAN&gt;&lt;SPAN&gt;] &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;byte&lt;/SPAN&gt;&lt;SPAN&gt;[] lpOutBuf,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;uint&lt;/SPAN&gt;&lt;SPAN&gt; nOutBufSize,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;out&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: 400; FONT-SIZE: 12px; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;uint&lt;/SPAN&gt;&lt;SPAN&gt; lpBytesReturned);&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;}&lt;BR&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=181067" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jehance/archive/tags/Samples+_2F00_+Snippets/default.aspx">Samples / Snippets</category></item><item><title>Why Doesn't My Desktop App Work on CF (Anymore)?</title><link>http://blogs.msdn.com/jehance/archive/2004/07/06/174387.aspx</link><pubDate>Tue, 06 Jul 2004 21:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:174387</guid><dc:creator>jehance</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jehance/comments/174387.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jehance/commentrss.aspx?PostID=174387</wfw:commentRss><description>&lt;P&gt;The Desktop Framework and the CF Framework have different Public Key Tokens as part of their strong name.&amp;nbsp; The Desktop framework commonly uses two different Key Tokens (b77a5c561934e089 and b03f5f7f11d50a3a), while CF currently uses one (969db8053d3322ac).&amp;nbsp; CF does not map Desktop references to CF assemblies, so any application referencing Desktop assemblies should never work on the Compact Framework because the references can not be&amp;nbsp;resolved at run time.&lt;/P&gt;
&lt;P&gt;&amp;#8220;Never?!?&amp;#8221; you say?&amp;nbsp; Well, okay, not exactly never.&amp;nbsp; There are two exceptions.&lt;/P&gt;
&lt;P&gt;The first exception is mscorlib.dll.&amp;nbsp; Currently, all shipping frameworks (including the Desktop framework) treat any references to any mscorlib as a reference to their own mscorlib.&amp;nbsp; There are multiple reasons for this, but the primary reason is that without mscorlib, an app can not even generate a managed exception, as all the basic types and exception types are housed in mscorlib.&amp;nbsp; Therefore, any app which uses things housed entirely within mscorlib &lt;STRONG&gt;&lt;EM&gt;should&lt;/EM&gt;&lt;/STRONG&gt; work on any .NET Framework.&amp;nbsp; That said, this is not a supported scenario and there are still cases where it will fail to work.&amp;nbsp; Primarily, there are things that exist within the Desktop's mscorlib that are not supported on CF.&amp;nbsp; A reference to something not supported on CF will still cause the app to fail when run against CF.&lt;/P&gt;
&lt;P&gt;The second exception is a bug that existed both in V1, and V1SP1 of CF, but was fixed in V1SP2 (and will remain fixed moving forward).&amp;nbsp; This bug allowed, under certain circumstances, Desktop references to be retargetted to CF assemblies if the CF assembly was already loaded.&amp;nbsp; This would happen for instance if, in a DLL, you referenced the Desktop System.Windows.Forms, but loaded the CF System.Windows.Forms in the application before using the DLL.&amp;nbsp; Unfortunately, the way that Visual Studio .NET 2003's&amp;nbsp;&amp;#8220;Add New Project&amp;#8221; wizard is structured, it is very easy to add a Desktop Class Library to a CF Project, so several applications were broken by this bug fix.&amp;nbsp; To add a CF Class Library to an existing CF Project, remember to select &amp;#8220;Smart Device Application&amp;#8221;, and then select &amp;#8220;Class Library&amp;#8221; on the first pane of the Wizard.&lt;/P&gt;
&lt;P&gt;-- jeh&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Disclaimer:&lt;BR&gt;This posting is provided &amp;#8220;AS IS&amp;#8221; with no warranties, and confers no rights&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=174387" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jehance/archive/tags/FAQs/default.aspx">FAQs</category></item><item><title>Now Open For Business</title><link>http://blogs.msdn.com/jehance/archive/2004/07/06/174206.aspx</link><pubDate>Tue, 06 Jul 2004 18:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:174206</guid><dc:creator>jehance</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/jehance/comments/174206.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jehance/commentrss.aspx?PostID=174206</wfw:commentRss><description>&lt;P&gt;My name is Jeremy Hance, and I'm an SDET on the Compact Framework team.&amp;nbsp; Officially, SDET = Software Development Engineer in Test.&amp;nbsp; In my position, I write code used to test the functionality of the Compact Framework.&amp;nbsp; Primarily, I work with the Global Assembly Cache (GAC), the Loader, and Native Interop (including COM Interop, which is new to V2).&lt;/P&gt;
&lt;P&gt;My intentions for this blog are fairly straight forward.&amp;nbsp; I'm looking for a place where I can post answers to questions I frequently find myself answering, and a place for posting code samples/snippets that I find myself repeatedly providing.&lt;/P&gt;
&lt;P&gt;Of course, like most things on the web, blogs are an active and constantly evolving art form, so we'll just have to see where this blog goes.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=174206" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jehance/archive/tags/Announcements/default.aspx">Announcements</category></item></channel></rss>