Sunday, 27 January 2013

Get operating system name using c#/VB.NET

Get operating system name using c#/Vb.NET

Add namespace Microsoft.Win32
        void GetWindowsPlatform()
        {
            OperatingSystem os=System.Environment.OSVersion;
            Console.WriteLine("OS Platform: {0}",os.Platform);
            Console.WriteLine("OS Service Pack: {0}",os.ServicePack);
            Console.WriteLine("OS Version: {0}",os.VersionString);
            String subKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion";
            RegistryKey key = Registry.LocalMachine;
            RegistryKey skey = key.OpenSubKey(subKey);
            Console.WriteLine("OS Name: {0}",skey.GetValue("ProductName"));
}
 for getting  Operating System Friendly Name for 32-bit & 64-bit  registry keys

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion  -->32-bit

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion -->64-bit

OUTPUT

OS Platform: Win32NT
OS Service Pack: Service Pack 1
OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
OS Name: Windows 7 Home Basic
 

Tags: get OS name,get OS friendly name,get OS version,get OS Service Pack,Get OS Platform,How to get OS Platform,How to get OS Version ,How to get OS Service Pack,get Operating System  name,get Operating System  friendly name,get Operating System  version,get Operating System  Service Pack,Get Operating System  Platform,How to get Operating System  Platform,How to get Operating System  Version ,How to get Operating System  Service Pack,

 

No comments:

Post a Comment