Click here to Skip to main content
15,878,959 members
Articles / Desktop Programming / Windows Forms
Tip/Trick

Make the programs work on a specific windows version

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
27 Sep 2010CPOL 8.6K   2   1
C#
private void Form1_Load(object sender, EventArgs e)
{
    if (!IsWin7())
    {
        Application.Exit();
    }
}
bool IsWin7()
{
    return Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1;
}
bool IsWinVista()
{
    return Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 0;
}


others windows versions:
Server 2008 R2
Major=6
Minor=1

Server 2008
Major=6
Minor=0

Server 2003
5
2

XP
5
1

2000
5
0

NT4
4
0

ME
4
90

98
4
10

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Jordan Jordan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralThe subject is misleading Pin
DaveAuld25-Sep-10 8:26
professionalDaveAuld25-Sep-10 8:26 

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.