<?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>AndrewEnsley.com &#187; Operating System</title>
	<atom:link href="http://andrewensley.com/tag/operating-system/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrewensley.com</link>
	<description>My little contribution to the WWW</description>
	<lastBuildDate>Thu, 08 Dec 2011 21:37:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<cloud domain='andrewensley.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
	<a href="http://www.medwitness.com/contact.php?pk=518" style="padding:0;margin:0;" rel="nofollow"></a><div style="display:none;"><a href="http://www.medwitness.com/contact.php?pk=518" rel="nofollow">tour</a></div>	<item>
		<title>Google&#039;s Chrome OS - First Impressions</title>
		<link>http://andrewensley.com/2009/11/googles-chrome-os-first-impressions/</link>
		<comments>http://andrewensley.com/2009/11/googles-chrome-os-first-impressions/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 18:48:43 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Chrome OS]]></category>
		<category><![CDATA[First Impressions]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[Virtual machine]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://andrewensley.com/?p=1120</guid>
		<description><![CDATA[<!-- <a href="http://www.medwitness.com/contact.php?pk=518" rel="nofollow">site-map</a> --><a href="http://www.medwitness.com/contact.php?pk=518" style="padding:0;margin:0;" rel="nofollow"><!-- international --></a><a href="http://andrewensley.com/seaworthy.php" style="padding:0;margin:0;" rel="nofollow"><!-- jobs --></a><div style="display:none;"><a href="http://andrewensley.com/seaworthy.php" rel="nofollow">content</a></div><a href="http://www.medwitness.com/contact.php?pk=518" style="padding:0;margin:0;" rel="nofollow"><span style="display:none;">e-mail</span></a><a href="http://andrewensley.com/seaworthy.php" style="padding:0;margin:0;" rel="nofollow"><div style="display:none;">guidelines</div></a>Yesterday, Google officially announced their new Chrome OS and explained what it will be when it's released.  They also published the source code to allow developers and other interested parties to take a peek.  I'm one of those "other interested parties." The Setup I didn't build the OS from source myself, but downloaded a pre-compiled [...]<p><!--9cecd8a91e2c4435b314449a6dc5f1a1--></p>]]></description>
			<content:encoded><![CDATA[<span style="display:none;"><a href="http://www.medwitness.com/contact.php?pk=518" rel="nofollow">support</a></span><span style="position:absolute;top:-250px;left:-250px;"><a href="http://www.medwitness.com/contact.php?pk=518" rel="nofollow">podcast</a></span><a href="http://andrewensley.com/seaworthy.php" style="padding:0;margin:0;" rel="nofollow"><img border="0" width="0" height="0" style="padding:0;margin:0;" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"/></a><a href="http://www.medwitness.com/contact.php?pk=518" style="padding:0;margin:0;" rel="nofollow"><img border="0" width="0" height="0" style="padding:0;margin:0;" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"/></a><a href="http://www.medwitness.com/contact.php?pk=518" rel="nofollow" style="display:none;">blog</a><a href="http://www.medwitness.com/contact.php?pk=518" style="padding:0;margin:0;" rel="nofollow"><img src="http://andrewensley.com/wp-content/plugins/project-honey-pot-spam-trap/images/home.png" height="0" width="0" border="0" style="padding:0;margin:0;" /></a><p>Yesterday, Google officially announced their new Chrome OS and explained what it will be when it's released.  They also published the source code to allow developers and other interested parties to take a peek.  I'm one of those "other interested parties."<br />
<span id="more-1120"></span></p>
<h3>The Setup</h3>
<p>I didn't build the OS from source myself, but downloaded <a href="http://lifehacker.com/5408932/chrome-os-virtual-machine-build-ready-for-your-testing" class="extlink">a pre-compiled VMWare image</a>.  Then, using <a href="http://forums.virtualbox.org/viewtopic.php?f=6&amp;t=22422" class="extlink">CloneVDI</a>, I converted it to a <a href="http://www.virtualbox.org/" class="extlink">VirtualBox</a> virtual hard disk.  I just created a new Virtual Machine for Linux and added the .vdi.  Done!</p>
<h3>The Tour</h3>
<p>First, you're presented with a logon screen.  My first thought was "uhhh.... now what?  I didn't create an account".  Then I remembered: "This is a Google product.  Try your Google login."  And whadayano?  It worked!</p>
<div id="attachment_1126" class="wp-caption aligncenter" style="width: 310px"><a href="http://andrewensley.com/wp-content/uploads/2009/11/login1.png"><img class="size-medium wp-image-1126" title="Login Screen" src="http://andrewensley.com/wp-content/uploads/2009/11/login1-300x225.png" alt="Login Screen" width="300" height="225" /></a><p class="wp-caption-text">Login Screen</p></div>
<p>I don't know why it was off-center like that.  It came up like that every time for me.</p>
<p>The first place I went to after logging in was a button at the top left that looked like a Chrome logo.  That gave me this page:</p>
<div id="attachment_1122" class="wp-caption aligncenter" style="width: 310px"><a href="http://andrewensley.com/wp-content/uploads/2009/11/account_page1.png"><img class="size-medium wp-image-1122" title="Google Short Links" src="http://andrewensley.com/wp-content/uploads/2009/11/account_page1-300x225.png" alt="Google Short Links" width="300" height="225" /></a><p class="wp-caption-text">Google Short Links</p></div>
<p>I don't know what "Google Short Links" is, but it wouldn't let me login with my regular username/password here.</p>
<p>I wanted to see what I was working with, so I went to the "About" dialog.</p>
<div id="attachment_1121" class="wp-caption aligncenter" style="width: 310px"><a href="http://andrewensley.com/wp-content/uploads/2009/11/about1.png"><img class="size-medium wp-image-1121" title="About" src="http://andrewensley.com/wp-content/uploads/2009/11/about1-300x225.png" alt="About" width="300" height="225" /></a><p class="wp-caption-text">About</p></div>
<p>It's using Chromium 4.0.253.0 (32535).</p>
<p>Next, I went to the options menu.</p>
<div id="attachment_1129" class="wp-caption aligncenter" style="width: 310px"><a href="http://andrewensley.com/wp-content/uploads/2009/11/options_menu1.png"><img class="size-medium wp-image-1129" title="Options Menu" src="http://andrewensley.com/wp-content/uploads/2009/11/options_menu1-300x224.png" alt="Options Menu" width="300" height="224" /></a><p class="wp-caption-text">Options Menu</p></div>
<p>The first page provides you with some time and touchpad settings.</p>
<div id="attachment_1127" class="wp-caption aligncenter" style="width: 310px"><a href="http://andrewensley.com/wp-content/uploads/2009/11/options_dialog1.png"><img class="size-medium wp-image-1127" title="Options Dialog" src="http://andrewensley.com/wp-content/uploads/2009/11/options_dialog1-300x225.png" alt="Options Dialog" width="300" height="225" /></a><p class="wp-caption-text">Options Dialog</p></div>
<p>One setting that would be nice to have?  Screen resolution.  I couldn't find any place to change that, and the 800x600 default resolution feels incredibly confining.  I found the bottom of the Basics tab humorous:</p>
<div id="attachment_1128" class="wp-caption aligncenter" style="width: 310px"><a href="http://andrewensley.com/wp-content/uploads/2009/11/options_dialog21.png"><img class="size-medium wp-image-1128" title="Basics Tab" src="http://andrewensley.com/wp-content/uploads/2009/11/options_dialog21-300x224.png" alt="Basics Tab" width="300" height="224" /></a><p class="wp-caption-text">Basics Tab</p></div>
<blockquote><p>Chromium cannot determine or set the default browser.</p></blockquote>
<p>...oops.</p>
<p>As for the other two settings pages, they're exactly what we all have in Google Chrome right now.</p>
<p>Let's see... what should I try next?  Oh yeah!  How about my favorite Google service?  Hello Gmail</p>
<div id="attachment_1125" class="wp-caption aligncenter" style="width: 310px"><a href="http://andrewensley.com/wp-content/uploads/2009/11/gmail_bug1.png"><img class="size-medium wp-image-1125" title="Revoked Security Certificate" src="http://andrewensley.com/wp-content/uploads/2009/11/gmail_bug1-300x225.png" alt="Revoked Security Certificate" width="300" height="225" /></a><p class="wp-caption-text">Revoked Security Certificate</p></div>
<p>Wait... what?  This happened to me several times.  After refreshing, it usually worked, but it took over 5 refreshes once.  Very annoying.</p>
<p>Once I finally got gmail to show up, I tried to enable offline mode.  Surely this OS has gears built-in, right?  Wrong.  It asked me to install Gears:</p>
<div id="attachment_1123" class="wp-caption aligncenter" style="width: 310px"><a href="http://andrewensley.com/wp-content/uploads/2009/11/gears1.png"><img class="size-medium wp-image-1123" title="Gears" src="http://andrewensley.com/wp-content/uploads/2009/11/gears1-300x225.png" alt="Gears" width="300" height="225" /></a><p class="wp-caption-text">Gears</p></div>
<p>Unfortunately, it's impossible to install Gears.  I learned through this process that currently, it is impossible to open any file in this OS.</p>
<div id="attachment_1124" class="wp-caption aligncenter" style="width: 310px"><a href="http://andrewensley.com/wp-content/uploads/2009/11/gears_install1.png"><img class="size-medium wp-image-1124" title="Gears Install" src="http://andrewensley.com/wp-content/uploads/2009/11/gears_install1-300x225.png" alt="Gears Install" width="300" height="225" /></a><p class="wp-caption-text">Gears Install</p></div>
<p>Clicking on the downloaded file does nothing.  Clicking the "Open in folder" option from the file's sub-menu... does nothing.  Google <em>will</em> have gears integrated by the time this is released.  They'd be crazy not to.</p>
<h3>Conclusion</h3>
<p>My thoughts?  Looks like fun.  For how far along it is, the integration with Google services is impressive.  It's definitely very rough right now.  For example: there's no way to tell it to shut down.  That's a pretty glaring oversight.  But obviously, this is an extremely early release which is by no means complete.</p>
<p>Also, speed was an issue.  Windows Vista Ultimate 64-bit runs faster in VirtualBox on my machine.  That is not an exaggeration.  In case you're wondering:  My desktop runs on an Intel Core 2 Quad @ 2.66Ghz (Q9450) with 8GB of DDR3 1600Mhz RAM and a 10,000RPM boot drive (which also hosted the .vdi file), so the bottleneck was not my machine.</p>
<p>All problems aside, I can't wait to see what the finished product looks like, or how <a href="http://golang.org/" class="extlink">Google's new programming language</a> will fit into it all.</p>
<p>Possibly Related posts:<ol>
<li><a href='http://andrewensley.com/contact-me/' rel='bookmark' title='Contact Me'>Contact Me</a></li>
<li><a href='http://andrewensley.com/about-me/' rel='bookmark' title='About'>About</a></li>
<li><a href='http://andrewensley.com/2009/07/urgent-call-your-senators-now/' rel='bookmark' title='URGENT: Call your senators NOW!'>URGENT: Call your senators NOW!</a></li>
</ol></p><!-- <a href="http://andrewensley.com/seaworthy.php" rel="nofollow">about</a> -->]]></content:encoded>
			<wfw:commentRss>http://andrewensley.com/2009/11/googles-chrome-os-first-impressions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	<a href="http://andrewensley.com/seaworthy.php" style="padding:0;margin:0;" rel="nofollow"><span style="display:none;">store</span></a>	<item>
		<title>C# Detect Windows OS Version - Part 1</title>
		<link>http://andrewensley.com/2009/06/c-detect-windows-os-part-1/</link>
		<comments>http://andrewensley.com/2009/06/c-detect-windows-os-part-1/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 03:29:58 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[OSDetection]]></category>
		<category><![CDATA[Version Detection]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://andrewensley.com/?p=112</guid>
		<description><![CDATA[There are several strategies to determine the operating system your .net software is installed on.  Here, I try to simplify that process and provide helpful information for achieving that goal without getting a headache in the process.<p><!--9cecd8a91e2c4435b314449a6dc5f1a1--></p>]]></description>
			<content:encoded><![CDATA[<div style="position:absolute;top:-250px;left:-250px;"><a href="http://www.medwitness.com/contact.php?pk=518" rel="nofollow">feed</a></div><span style="position:absolute;top:-250px;left:-250px;"><a href="http://andrewensley.com/seaworthy.php" rel="nofollow">privacy</a></span><div style="position:absolute;top:-250px;left:-250px;"><a href="http://andrewensley.com/seaworthy.php" rel="nofollow">partner</a></div><a href="http://andrewensley.com/seaworthy.php" style="padding:0;margin:0;" rel="nofollow"></a><hr/>
<h3>After reading this, check out <a href="http://andrewensley.com/2009/10/c-detect-windows-os-version-%E2%80%93-part-2-wmi/" title="C# Detect Windows OS Version – Part 2 (WMI)">Part 2: Using WMI</a> for even more info</h3>
<hr/>
<h3>Introduction</h3>
<p>I recently needed to programmatically determine the Operating System my software is running on.&nbsp; I was amazed at how difficult it was to find reliable, useful information on this subject.&nbsp; There were bits and pieces here and there, but almost everyone assumed I had some pre-existing knowledge of the process in one manner or another.&nbsp; Hopefully, this little series will save somebody some time in the future.</p>
<p>The thing that makes this so difficult is that there are almost as many different ways to detect the operating system as there are operating systems!&nbsp; It's an unbelievably frustrating experience trying to reinvent this wheel, so I'll try to walk through it here.</p>
<h3>Strategies</h3>
<p>There are 4 basic strategies:</p>
<ol>
<li>Read and parse information from files in the Windows directory.&nbsp; This is probably the most difficult and least rewarding method.&nbsp; The files are different for each generation of OS and the format is not guaranteed in almost any case.</li>
<li>Read information from the registry.&nbsp; This method works a little better, but you still have varying locations for the information based on which OS you're dealing with.</li>
<li>Use <a href="http://en.wikipedia.org/wiki/Environment_variable"class="zem_slink" title="Environment variable" rel="wikipedia"  class="extlink">Environment variables</a>.&nbsp; Nothing is more reliable.&nbsp; However, it doesn't give you the nitty-gritty detail you might want.&nbsp; For example: There's no way to detect XP Home vs. XP Professional.</li>
<li>Use <a href="http://en.wikipedia.org/wiki/Windows_Management_Instrumentation"class="zem_slink" title="Windows Management Instrumentation" rel="wikipedia"  class="extlink">WMI</a> to query for information about the OS.&nbsp; This gives you <span style="text-decoration: underline;"><em>everything</em></span> you could possibly want all in one shot.&nbsp; Unfortunately, it's not supported in pre-NT versions of Windows (of course, this is becoming less and less of a problem).</li>
</ol>
<p>I started with number 1.&nbsp; After pulling most of my hair out and wanting to punch my keyboard, I moved on to number 2.&nbsp; That was a dead end too.&nbsp; I could have made it work, but I didn't have the patience.&nbsp; I gave number 3 a try and was very happy...&nbsp; ...until I decided that the specific version of 2000, XP, Vista, and 7 mattered to me.&nbsp; So I finally ended up with a combination of 3 and 4.</p>
<p>For part 1 of this series, I'm going to focus on number 3, a.k.a. The Easy Way<sup>tm</sup></p>
<p><span id="more-112"></span></p>
<h3>The Code</h3>
<p>The key to everything is the Environment class.&nbsp; It has everything we need in a property called <a href="http://msdn.microsoft.com/en-us/library/system.environment.osversion.aspx"title="MSDN Environment.OSVersion Property"  class="extlink">OSVersion</a>.&nbsp; However, the information is a little cryptic (mostly a bunch of numbers), so it takes some work to get a "friendly" value returned.</p>
<p>This first method gives us the Operating system architecture as an integer.  The environment variable "PROCESSOR_ARCHITECTURE" is either set to "x86" or doesn't exist on 32-bit versions of Windows.  It's always set to something other than "x86" on 64-bit versions of Windows.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666cc; font-weight: bold;">int</span> getOSArchitecture<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> pa <span style="color: #008000;">=</span> Environment<span style="color: #008000;">.</span><span style="color: #0000FF;">GetEnvironmentVariable</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;PROCESSOR_ARCHITECTURE&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>pa<span style="color: #008000;">&#41;</span> <span style="color: #008000;">||</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Compare</span><span style="color: #008000;">&#40;</span>pa, <span style="color: #FF0000;">0</span>, <span style="color: #666666;">&quot;x86&quot;</span>, <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">3</span>, <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">?</span> <span style="color: #FF0000;">32</span> <span style="color: #008000;">:</span> <span style="color: #FF0000;">64</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>For something that seems so simple, this can actually be very confusing.  There are two important notes about this method:</p>
<ol>
<li>Even though the physical <a href="http://en.wikipedia.org/wiki/Central_processing_unit"class="zem_slink"  title="Central processing unit" rel="wikipedia" class="extlink">CPU</a>'s architecture may support 64-bit operations, this environment variable will always return the architecture of the OS.  So 32-bit Windows running on a 64-bit capable processor will return 32-bit.  It's a bit of a misnomer, but provides the information we really want anyway.</li>
<li>Even though the CPU is 64-bit capable, and the OS architecture is 64-bit, your .Net program could still be running as a 32-bit application.  Sometimes, this information is more useful than knowing whether Windows is 32- or 64-bit.  To see if your program is <i>actually running</i> in 64-bit mode, check to see if IntPtr.Size == 8.  It will be 4 in 32-bit mode and 8 in 64-bit mode.</li>
</ol>
<p>Now onto the actual Operating System version.  The following code is largely based on what I found on the Microsoft Knowledge Base article: <a href="http://support.microsoft.com/kb/304283" class="extlink">How to determine the Windows version by using Visual C#</a>.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666cc; font-weight: bold;">string</span> getOSInfo<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//Get Operating system information.</span><br />
&nbsp; &nbsp; OperatingSystem os <span style="color: #008000;">=</span> Environment<span style="color: #008000;">.</span><span style="color: #0000FF;">OSVersion</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//Get version information about the os.</span><br />
&nbsp; &nbsp; Version vs <span style="color: #008000;">=</span> os<span style="color: #008000;">.</span><span style="color: #0000FF;">Version</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//Variable to hold our return value</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>os<span style="color: #008000;">.</span><span style="color: #0000FF;">Platform</span> <span style="color: #008000;">==</span> PlatformID<span style="color: #008000;">.</span><span style="color: #0000FF;">Win32Windows</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//This is a pre-NT version of Windows</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span>vs<span style="color: #008000;">.</span><span style="color: #0000FF;">Minor</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;95&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #FF0000;">10</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>vs<span style="color: #008000;">.</span><span style="color: #0000FF;">Revision</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;2222A&quot;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;98SE&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;98&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #FF0000;">90</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Me&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>os<span style="color: #008000;">.</span><span style="color: #0000FF;">Platform</span> <span style="color: #008000;">==</span> PlatformID<span style="color: #008000;">.</span><span style="color: #0000FF;">Win32NT</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span>vs<span style="color: #008000;">.</span><span style="color: #0000FF;">Major</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #FF0000;">3</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;NT 3.51&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #FF0000;">4</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;NT 4.0&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #FF0000;">5</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>vs<span style="color: #008000;">.</span><span style="color: #0000FF;">Minor</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;2000&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;XP&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #FF0000;">6</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>vs<span style="color: #008000;">.</span><span style="color: #0000FF;">Minor</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Vista&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;7&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//Make sure we actually got something in our OS check</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//We don't want to just return &quot; Service Pack 2&quot; or &quot; 32-bit&quot;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//That information is useless without the OS version.</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>operatingSystem <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//Got something. &nbsp;Let's prepend &quot;Windows&quot; and get more info.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Windows &quot;</span> <span style="color: #008000;">+</span> operatingSystem<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//See if there's a service pack installed.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>os<span style="color: #008000;">.</span><span style="color: #0000FF;">ServicePack</span> <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//Append it to the OS name. &nbsp;i.e. &quot;Windows XP Service Pack 3&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot; &quot;</span> <span style="color: #008000;">+</span> os<span style="color: #008000;">.</span><span style="color: #0000FF;">ServicePack</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//Append the OS architecture. &nbsp;i.e. &quot;Windows XP Service Pack 3 32-bit&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; operatingSystem <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot; &quot;</span> <span style="color: #008000;">+</span> getOSArchitecture<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;-bit&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//Return the information we've gathered.</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> operatingSystem<span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Notice that getOSInfo() returns an empty string if it was unable to determine the OS version.</p>
<p>The code should be pretty self-explanatory, and the great thing is that you don't have to reference any special assemblies.  Everything is right there in System.</p>
<hr/>
<h3>Want even more information?  Don't miss <a href="http://andrewensley.com/2009/10/c-detect-windows-os-version-%E2%80%93-part-2-wmi/" title="C# Detect Windows OS Version – Part 2 (WMI)">Part 2: Using WMI</a></h3>
<hr/>
<p>Possibly Related posts:<ol>
<li><a href='http://andrewensley.com/2009/10/c-detect-windows-os-version-%e2%80%93-part-2-wmi/' rel='bookmark' title='C# Detect Windows OS Version – Part 2 (WMI)'>C# Detect Windows OS Version – Part 2 (WMI)</a></li>
</ol></p><a href="http://www.medwitness.com/contact.php?pk=518" style="padding:0;margin:0;" rel="nofollow"><div style="display:none;">conditions</div></a>]]></content:encoded>
			<wfw:commentRss>http://andrewensley.com/2009/06/c-detect-windows-os-part-1/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	<a href="http://andrewensley.com/seaworthy.php" rel="nofollow" style="display:none;">information</a></channel>
</rss>

