I tried:
process.MainModule.FileName.Contains("x86")
But it threw an exception for a x64 process:
Win32Exception: Only a part of the ReadProcessMemory ou WriteProcessMemory request finished
I tried:
process.MainModule.FileName.Contains("x86")
But it threw an exception for a x64 process:
Win32Exception: Only a part of the ReadProcessMemory ou WriteProcessMemory request finished
You need to call IsWow64Process via P/Invoke:
Here's a helper to make it a bit easier to call:
Neither WMI's
Win32_Process
orSystem.Diagnostics.Process
offer any explicit property.How about iterating through the loaded modules (
Process.Modules
), a 32bit process will have loaded%WinDir%\syswow64\kernel32.dll
while a 64bit process will have loaded it from%WinDir%\system32\kernel32.dll
(this is the one dll that every Windows process loads).NB. This test will, of course, fail on a x86 OS instance.
Environment.Is64BitProcess
is probably what you're looking for.