Sometimes you might want to check for which Windows “edition” is installed on a computer. Let’s say you’ve made an app that you want to be free for personal use, but want to force enterprises to pay a licensing fee if they want to use it in their environment.
A quick and dirty registry key check performed in the startup sequence of your application can be enough to find whether the Windows “edition” installed is Home Basic, Home Premium, Ultimate or Enterprise.
To determine which Windows Edition a computer is installed with, simply check the value of the following registry key:
A simple example (in pseudo code) to test for this registry key value in C#:
- First, use the Microsoft.Win32.RegistryKey class (click the link for details about the class at MSDN)
- Then use OpenSubKey to open HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
- You then call GetSubKeyNames to fetch the names of the subkeys under CurrentVersion
- Call GetValue for the key value you want, which in this case would be EditionID
- Check if the value matches Enterprise. If the value is a match, you might want to display a warning or ask for a serial key to allow the user to use the application
There’re more potentially helpful registry keys under the CurrentVersion path, here’s a list of a few of them (I chose to leave out the most obscure ones):
The current build number. Both of these keys have the same value whenever I have checked. My Windows 7 SP1 Ultimate has a build number of 7601.
The current “version” of Windows. My Windows 7 SP1 Ultimate has the version number “6.1”.
The installation type. Has the value of “Client” on my computer. Can be “Server” on servers like Windows 2008 R2.
The “marketing name” of the current Windows installation. On my computer the value is “Windows 7 Ultimate”.
Empty value on my PC, this value is usually populated with the company name in an Enterprise installaton.
Contains the name of the “owner”. Usually the same as the first user name that is created during setup, or company name in an Enterprise install.
The name of the latest service pack installed, if any. Can be empty if no service pack is installed. On my PC the value is “Service Pack 1”.
The build number of the latest service pack installed, if any. Can be empty if no service pack is installed. On my PC the value is “1130”.
If performing many queries against the registry or other parts of the system, check out the little known Microsoft tool Log Parser. Log Parser can query the registry, file system, system event log or even values inside of XML and CSV files.
To use LogParser within C#, you need to build an Interop Assembly from the Logparser.dll COM server using the following command (correct the path to your installation of Log Parser, for exampe to “Program Files (x86)” on 64-bit systems):
tlbimp "C:\Program Files\Log Parser 2.2\LogParser.dll" /out:Interop.MSUtil.dll
using LogQuery = Interop.MSUtil.LogQueryClass;
using RegistryInputFormat = Interop.MSUtil.COMRegistryInputContextClass;
using RegRecordSet = Interop.MSUtil.ILogRecordset;
public static void Main()
RegRecordSet registryRecords = null;
LogQuery qry = new LogQuery();
RegistryInputFormat registryFormat = new RegistryInputFormat();
string query = @"SELECT Path from \HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion where Value='Enterprise'";