tags:

views:

85

answers:

3

Hello, trying to find thid issue in the database with no luck.

So, I'm developing on a 64bit system (windows seven). I'm making a simple console programme that check if a dll is present on the windows system. in that case i check in the system32 folder and then, in the sysWOW64 folder. The pro gramme is 32bit application.

On a 32bit target platform, i can check normally the win32dll, as the SysWOW64 directory doesn't exist, no problem. Bit when it execute on a 64bit system i can check the win32 directory, but the sysWOW64 directory always me point to the system32 directory.

It seems that on 64bit system there is a kind of redirection.

I'm trying to use the "Wow64DisableWow64FsRedirection" but i have "error C3861: 'Wow64DisableWow64FsRedirection': identifier not found" when i compile.

So ther is too question :

  • In winbase.h this fuction is disabled, how to get it work ?
  • How to determine if i'm currently on a 32 or 64 bit system as programme is running ?

Many thanks.

A: 

About How to determine if i'm currently on a 32 or 64 bit system, I think that you could check the size of an int pointer...

int bits = IntPtr.Size * 8;
Console.WriteLine( "{0}-bit", bits );
Jonathan
well i check with this exemple : http://blogs.msdn.com/b/oldnewthing/archive/2005/02/01/364563.aspx
Ziggy
Note: The size of `IntPtr` depends on whether you are in a 32-bit or 64-bit *process*. It doesn't tell you about the underlying OS. To get information on the OS see http://stackoverflow.com/questions/336633/how-to-detect-windows-64-bit-platform-with-net. Besides, the OP does not seem to use .NET
0xA3
I think this code is simpler and have a better performance. Only one line to get the answer! :D
Jonathan
0xA3 is right... if you're looking for the OS version, this is not the right answer :(
Jonathan
+2  A: 

You don't have to search for DLLs. LoadLibrary() and LoadLibraryEx() will automatically search all relevant folders for you.

The search order is as follows:

  1. The directory from which the application loaded.
  2. The system directory.
  3. The 16-bit system directory.
  4. The Windows directory
  5. The current directory.
  6. The directories that are listed in the PATH environment variable.

If you're sure that you want to disable the redirection you can do so with Wow64DisableWow64FsRedirection as you mentioned. To make it "work", you have to set

#define _WIN32_WINNT 0x0501 (or higher)

before you include windows.h

A: 

While not perhaps what you're looking for, slightly wasteful if you know those are the only two places the file could be located, and possibly wouldn't work if the user has modified them (Although a whole host of other things will have broken for the user too), you could simply use the %Path% environmental variable.

JBirch