Skip to content

Instantly share code, notes, and snippets.

@fresky
Created October 9, 2012 07:25
Show Gist options
  • Save fresky/3857167 to your computer and use it in GitHub Desktop.
Save fresky/3857167 to your computer and use it in GitHub Desktop.
Check one process is 32bit or 64bit
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