WOW64 file system redirection only makes sense when running under WOW64. As such, the function only works on a 32 bit process running on a 64 bit system, that is under WOW64. The function if available for a 64 bit process, but always fails (returns FALSE
). And the function is not available on a 32 bit system.
So, you must not use load-time linking for the function, if you want your program to run on a 32 bit OS. And you must expect it to fail if you call it from a 64 bit process.
If you are going to disable file system redirection then you should:
- Use runtime linking. That is with calls to
GetModuleHandle('kernel32')
and GetProcAddress()
.
- Add code to handle the fact that
GetProcAddress()
may return NULL
. In that scenario you just skip the calls that disable file system redirection.
- Skip the calls to disable file system redirection if your process is 64 bit because they always fail.
Now, there are very few scenarios where disabling file system redirection is appropriate. Generally, in my experience, if a developer is savvy enough to recognise such a scenario, then they are also savvy enough to deal with the three points I listed above. So, it seems plausible to me that your code should not be disabling file system redirection at all. I wonder if there is a better solution to whatever problem led you to disable file system redirection