In C#, how can I know programmatically if the Operating system is x64 or x86
I found this API method on the internet, but it doesn’t work
[DllImport("kernel32.dll")]
public static extern bool IsWow64Process(System.IntPtr hProcess, out bool lpSystemInfo);
public static bool IsWow64Process1
{
get
{
bool retVal = false;
IsWow64Process(System.Diagnostics.Process.GetCurrentProcess().Handle, out retVal);
return retVal;
}
}
Thanks in advance.
In .NET 4.0 you can use the new Environment.Is64BitOperatingSystem property.
And this is how it’s impemented
Use reflector or similar to see exactly how it works.