Hi Hamed,
How can I check what is the Windows version and if it is Windows XP, is
SP2 of Windows XP installed?
To do this, you would use the System.Environment class and it's OSVersion
property. Assuming you are using .NET 2.0, here's the C# code you need:
------------------------
OperatingSystem os = System.Environment.OSVersion;
if ((os.Platform == PlatformID.Win32NT) &&
(os.Version.Major == 5) &&
(os.Version.Minor == 1))
{
// this is Windows NT 5.1, or Windows XP
string sp = os.ServicePack;
if (sp == "Service Pack 2")
{
MessageBox.Show("This is Windows XP with SP2!");
}
}
------------------------
Warning: This kind of code is bad code. You should never hardcode your
application so that it only works with certain operating system version or
service pack. For example, Windows Vista is soon here, or there might be
Windows XP SP3. Your application must run under Vista and other future
operating systems.
Hope this helps!
--
Regards,
Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethis.dystopia.fi http://www.saunalahti.fi/janij/