1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Hardware/OperatingSystem.cs Wed Jul 11 22:28:39 2012 +0000
1.3 @@ -0,0 +1,38 @@
1.4 +/*
1.5 +
1.6 + This Source Code Form is subject to the terms of the Mozilla Public
1.7 + License, v. 2.0. If a copy of the MPL was not distributed with this
1.8 + file, You can obtain one at http://mozilla.org/MPL/2.0/.
1.9 +
1.10 + Copyright (C) 2012 Michael Möller <mmoeller@openhardwaremonitor.org>
1.11 +
1.12 +*/
1.13 +
1.14 +using System;
1.15 +using System.Diagnostics;
1.16 +using System.Runtime.InteropServices;
1.17 +
1.18 +namespace OpenHardwareMonitor.Hardware {
1.19 + internal static class OperatingSystem {
1.20 +
1.21 + public static bool Is64BitOperatingSystem() {
1.22 + if (IntPtr.Size == 8)
1.23 + return true;
1.24 +
1.25 + try {
1.26 + bool wow64Process;
1.27 + bool result = IsWow64Process(
1.28 + Process.GetCurrentProcess().Handle, out wow64Process);
1.29 +
1.30 + return result && wow64Process;
1.31 + } catch (EntryPointNotFoundException) {
1.32 + return false;
1.33 + }
1.34 + }
1.35 +
1.36 + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
1.37 + [return: MarshalAs(UnmanagedType.Bool)]
1.38 + private static extern bool IsWow64Process(IntPtr hProcess,
1.39 + out bool wow64Process);
1.40 + }
1.41 +}