C #32-bit programs run in 64-bit systems to solve the redirection problem,

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.