SN Ngaihte

Hi there,

How do I find out programatically in C# that my OS is x86(32bit) or x64(64bit) platform

Thanks a lot

Suan Ngaihte




Re: Visual C# General How do I find that an OS is x86 or x64

TilakGopi

Hi,

I've used Management class for this purpose.

Add System.Management reference to ur project.

And try the following snippet on ur machine.It's showing all the properties except few(OSArchitecture is also not shown).It may be shown on ur machine.

try.


ManagementClass class1 = new ManagementClass("Win32_OperatingSystem");

foreach (ManagementObject ob in class1.GetInstances())
{
int index = 1;

foreach (PropertyData pd in ob.Properties)
{
string str = index.ToString() + ")" + pd.Name + " = ";
if (pd.Value != null)
str += pd.Value.ToString();
MessageBox.Show(str);
index++;
}

}


 

 U can get  processor type using " win32_processor".

For more information on these things ,refer :

http://msdn2.microsoft.com/en-us/library/aa394084.aspx

 

Thanx,

Ch.T.Gopi Kumar.






Re: Visual C# General How do I find that an OS is x86 or x64

Peter Ritchie

Stolen from Chris Mullins:
public static bool IsRunningOnWin64()
{
return (IntPtr.Size == 8);
}