tags:

views:

198

answers:

1

I've got a Win32 process that is compiled and packaged in both 32-bit (x86) and 64-bit (x64) variants. I'd like the x86 variant to refuse to run on a 64-bit version of Windows (i.e. WOW64).

Is there any way to do this by setting linker flags? If not, what do I need to do?

+2  A: 

You can check whether you're running under emulation by calling IsWow64Process. Note, that you may need to load the function dynamically if you want to support older versions the OS.

avakar
I'd prefer a solution that stops the process from loading entirely (i.e. EXE header flags), but if there isn't one, then this is what I'll do...
Roger Lipscombe
I believe there is no such flag. May I ask what motivates you to prevent WOW64 execution?
avakar
The process enumerates other processes and windows. Rather than jump through hoops to get it to work correctly on WOW64, I'd rather just build it for x64, and prevent the x86 version from ever running on WOW64. It's also one fewer entry on the test matrix, which'll make my QA team happier.
Roger Lipscombe