public static bool Is64BitProcess( int pid ) { SYSTEM_INFO si = new SYSTEM_INFO(); UnsafeFunctions.GetNativeSystemInfo(ref si); if (si.processorArchitecture == 0) { return false; } IntPtr hProcess = UnsafeFunctions.OpenProcess(ProcessAccessFlags.QueryInformation, false, pid); if (IntPtr.Zero == hProcess) { throw new Exception("Cann't open process."); } bool result; if (!UnsafeFunctions.IsWow64Process(hProcess, out result)) { UnsafeFunctions.CloseHandle(hProcess); throw new InvalidOperationException(); } UnsafeFunctions.CloseHandle(hProcess); return !result; }
public static extern void GetNativeSystemInfo(ref SYSTEM_INFO si);
public static extern void GetNativeSystemInfo( ref SYSTEM_INFO si );