Hi,
I am using the forum's recommended way (http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/24792cdc-2d8e-454b-9c68-31a19892ca53/) of detecting a 32-bit program running under Wow64 on a 64-bit Vista system, and it used to work - it reported a 32-bit process running under Wow64 on a 64-bit system. After a couple of months (I don't know exaclty when), this method is now reporting that - when I compile my class as x86 (32-bit) in Visual Studio 2010 SP1 - the method IsWow64Process does not exist in Kernel32.dll. I am running Windows Vista Ultimate SP2 on a 64-bit HP PC. I first check if the IntPtr is 8 bits - which it isn't because I have a 32-bit process. Then I check if the Kernel32.dll is present - it is. Then I check if the IsWow64Process method is present in Kernetl32.dll - and it is NOT. I am positive this used to work a couple of months ago. I moved the methods to a separate class (NativeMethods) to satisfy the Code Analysis tool, but no other changes were made. If I compile the classe as x64, then the same code reports a 64-bit process because the IntPtr is 8 bits big.
Code extract:
{
// The Kernelt32.dll module which can contain the "IsWow64Process" method exists. Now see if the method "IsWow64Process" exists in this module.
IntPtr methodHandle = GetProcAddress(moduleHandle, "IsWow64Process");
if (methodHandle == IntPtr.Zero)
{
// The method "IsWow64Process" does not exist, so we are running on a 32-bit system. This is NOT true as I am running
on a 64-bit machine.
// Set the system architecture.
systemArch = "32-bit";
}
else
{ // code which should be reached but is not... }
}
Can the way Visual Studio is told to compile (32 or 64 bit, AnyCPU, Target Platform) affect the way this works ?
Any help appreciated.
Thanks and regards
Keith