moel@361: /*
moel@361:  
moel@361:   This Source Code Form is subject to the terms of the Mozilla Public
moel@361:   License, v. 2.0. If a copy of the MPL was not distributed with this
moel@361:   file, You can obtain one at http://mozilla.org/MPL/2.0/.
moel@361:  
moel@361:   Copyright (C) 2012 Michael Möller <mmoeller@openhardwaremonitor.org>
moel@361: 	
moel@361: */
moel@361: 
moel@361: using System;
moel@361: using System.Diagnostics;
moel@361: using System.Runtime.InteropServices;
moel@361: 
moel@361: namespace OpenHardwareMonitor.Hardware {
moel@361:   internal static class OperatingSystem {
moel@361: 
moel@361:     public static bool Is64BitOperatingSystem() {
moel@361:       if (IntPtr.Size == 8)
moel@361:         return true;
moel@361: 
moel@361:       try {
moel@361:         bool wow64Process;
moel@361:         bool result = IsWow64Process(
moel@361:           Process.GetCurrentProcess().Handle, out wow64Process);
moel@361: 
moel@361:         return result && wow64Process;
moel@361:       } catch (EntryPointNotFoundException) {
moel@361:         return false;
moel@361:       }
moel@361:     }
moel@361: 
moel@361:     [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
moel@361:     [return: MarshalAs(UnmanagedType.Bool)]
moel@361:     private static extern bool IsWow64Process(IntPtr hProcess,
moel@361:       out bool wow64Process);
moel@361:   }
moel@361: }