Created
October 9, 2012 07:25
-
-
Save fresky/3857167 to your computer and use it in GitHub Desktop.
Check one process is 32bit or 64bit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class ProcessDetector | |
{ | |
public static bool IsWin64(Process process) | |
{ | |
if (Environment.Is64BitOperatingSystem) | |
{ | |
IntPtr processHandle; | |
bool retVal; | |
try | |
{ | |
processHandle = Process.GetProcessById(process.Id).Handle; | |
} | |
catch | |
{ | |
return false; | |
} | |
return Win32API.IsWow64Process(processHandle, out retVal) && retVal; | |
} | |
return false; | |
} | |
} | |
internal static class Win32API | |
{ | |
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
internal static extern bool IsWow64Process([In] IntPtr process, [Out] out bool wow64Process); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment