public static bool Is64BitOperatingSystem
{
[SecuritySafeCritical]
get
bool flag;
return ((Win32Native.DoesWin32MethodExist("kernel32.dll", "IsWow64Process")
&& Win32Native.IsWow64Process(Win32Native.GetCurrentProcess(), out flag)) && flag);
}
return true;
return IntPtr.Size == 8 || ((Win32Native.DoesWin32MethodExist("kernel32.dll", "IsWow64Process")
[SuppressUnmanagedCodeSecurity, SecurityCritical]
internal static class Win32Native
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern IntPtr GetCurrentProcess();
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("kernel32.dll", SetLastError = true)]
internal static extern bool IsWow64Process([In] IntPtr hSourceProcessHandle, [Out] out bool isWow64);
[SecurityCritical]
internal static bool DoesWin32MethodExist(string moduleName, string methodName)
IntPtr moduleHandle = GetModuleHandle(moduleName);
if (moduleHandle == IntPtr.Zero)
return false;
return (GetProcAddress(moduleHandle, methodName) != IntPtr.Zero);
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail),
DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr GetModuleHandle(string moduleName);
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern IntPtr GetProcAddress(IntPtr hModule, string methodName);