Click here to Skip to main content
15,033,303 members
Articles / Operating Systems / Windows
Posted 2 Jan 2007


15 bookmarked

Determining the specific edition of Windows for now and in the future

Rate me:
Please Sign up or sign in to vote.
3.14/5 (4 votes)
2 Jan 20072 min read
This article describes how to determine the specific edition of Windows that your application is running on even if that version does not yet exist.


While determining the version number of the copy of Windows that a .NET application is running on has been relatively easy with Environment.OSVersion. Knowing exactly which version of Windows it is and what edition it is (Home, Pro, Tablet, Media Center, N, etc) has been a bit more difficult and an ever changing edition set assumes one is actually detectable.

With the introduction of Windows Vista and it's 9 different editions, it seemed as if being able to easily tell the difference between them was going to be even more difficult... not so.

At last Microsoft has provided a simple API for determining which Windows edition (a.k.a. SKU or product type) is being run within a general family as well as provides a way for you to be aware of future versions of Windows without having to change your application down the line.

I present GetProductInfo:

internal static extern bool GetProductInfo(
    int osMajorVersion,
    int osMinorVersion,
    int spMajorVersion,
    int spMinorVersion,
    out ProductType edition);


In order to determine which edition of Windows a PC is running, one need only call GetProductInfo and capture the output value of the last parameter if the method call is successful:

ProductType edition = ProductType.Undefined;

if (GetProductInfo(6, 0, 0, 0, out edition))
    Console.WriteLine("Edition: " + edition);

If we want to be less specific than just a specific version (i.e. Ultimate or not), we can also use a quick switch block to see if the version is of a specific type:

switch (edition)
    case ProductType.HomeBasic:
    case ProductType.HomeBasicN:
    case ProductType.HomePremium:
    case ProductType.HomeServer:
    //Is home edition

The Future

But how does this make your code able to deal with future unannounced or unknown versions? Why are we arbitrarily specifying a version number in our API call?

The enum that GetProductInfo() uses today is tied to the version of Windows (Vista) and in later versions will likely be updated along with a new version number while still retaining awareness of the old one(s).

This means that when your application built today against Vista is run on a future system that uses a different ProductType value, the API will recognize that your app is only aware of ProductTypes that existed in the version of the enum, and return a value of that type instead of returning an unknown value.

Take the switch statement from above... what happens if in the future Microsoft releases Windows Home Edition for Kids and that has a ProductType value of HomeKids... rather than returning an unknown value, you might receive HomeBasic back instead because you have already specified the version of the enum you are aware of.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Brendan Grant
Web Developer
United States United States
No Biography provided

Comments and Discussions

GeneralGet Description Pin
shawkins25-Jan-07 12:25
Membershawkins25-Jan-07 12:25 
AnswerRe: Get Description Pin
Isaak Newton16-Nov-08 7:55
MemberIsaak Newton16-Nov-08 7:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.