C #32-bit programs run in 64-bit systems to solve the redirection problem,
In a 64-bit Windows operating system, a 64-bit Windows operating system adopts a redirection mechanism to ensure compatibility with 32-bit programs. The objective is to allow 32-bit programs in 64-bit operating systems not only to operate on key file folders and key registries, but also to avoid conflicts with 64-bit programs
In a 64-bit Windows operating system, 32-bit applications can be run, which is achieved through a simulator called WOW64. WOW64 is a compatible environment provided by the operating system. It enables 32-bit applications to run on a Windows 64-bit operating system. In the Windows directory of the system, there are two folders: System32 and SysWOW64:
The 64-bit DLL is stored in the System32 folder.
The SysWOW64 folder stores 32-bit DLL
Similarly:
64-bit applications are saved in the Program File folder.
32-bit applications are saved in the Program File (X86) folder.
The Registry also has two sets.
Even if an absolute path is specified, such as "% windir %/System32", the system automatically redirects to the corresponding directory based on different calling programs.
The solution to disabling system redirection is to call the following API functions.
To disable system redirection, use the following function:
BOOL Wow64DisableWow64FsRedirection (PVOIDOldValue);
Use the following function to restore system redirection:
BOOL Wow64RevertWow64FsRedirection (PVOIDOldValue);
The following is a reference to these two functions in C:
// Disable the 64-bit (File System) operation redirection
[DllImport ("Kernel32.dll", CharSet = CharSet. auto, SetLastError = true)] public static extern bool Wow64DisableWow64FsRedirection (ref IntPtr ptr); // switch the 64-bit (File System) operation to [DllImport ("Kernel32.dll ", charSet = CharSet. auto, SetLastError = true)] public static extern bool Wow64RevertWow64FsRedirection (IntPtr );
Omitting the relevant code .......
IntPtr oldWOW64State = new IntPtr ();
Wow64DisableWow64FsRedirection (ref oldWOW64State); // disable the 64-bit (File System) operation redirection.
Omitting relevant code (such as file operations in the system directory ).....
Wow64RevertWow64FsRedirection (oldWOW64State); // turn on the 64-bit (File System) Operation
Address: http://www.cnblogs.com/iamlucky/p/5998086.html