views:

96

answers:

3

How do I know the bitness of some process which is in running state. (Not the current one.. where IntPtr.size is useful) iswow64process()... gives only whether it is a WoW64 process, but doesn't output 32/64 bit.. could anybody pl help..

+4  A: 

If you know you are running on 64-bit windows then if it a process is running in WoW64 mode then it must be 32-bit (that is what WoW64 is for - running 32-bit applications on 64-bit Windows), if not then you can assume 64-bit.

From MSDN:

WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows.

Also from here:

[IsWow64Process] A pointer to a value that is set to TRUE if the process is running under WOW64. If the process is running under 32-bit Windows, the value is set to FALSE. If the process is a 64-bit application running under 64-bit Windows, the value is also set to FALSE.

Paolo
+1  A: 

IsWow64Process is the right approach. Running under WOW64 is only true for a 32bit process on a 64bit OS.

Richard
+2  A: 

The real trouble is finding out that you are running on a 64-bit version of Windows. Using IntPtr.Size isn't good enough, your program might have been forced to run in 32-bit mode. You'll have to P/Invoke GetNativeSystemInfo() to get SYSTEM_INFO.wProcessorArchitecture.

Watch out for exceptions from these P/Invokes, the API functions are not available in XP and earlier. When you get one from IsWow64Process then you'll know it is a 32-bit OS. You can avoid the exception with LoadLibrary and GetProcAddress.

Hans Passant