Click to Rate and Give Feedback
MSDN
MSDN Library
System Services
File Services
File Systems
File Management
 Wow64DisableWow64FsRedirection Func...
Wow64DisableWow64FsRedirection Function

Disables file system redirection for the calling thread. File system redirection is enabled by default.

Syntax

BOOL WINAPI Wow64DisableWow64FsRedirection(
  __out  PVOID *OldValue
);

Parameters

OldValue [out]

The WOW64 file system redirection value.

Return Value

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.

Remarks

To restore file system redirection, call the Wow64RevertWow64FsRedirection function.

To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0501 or later. For more information, see Using the Windows Headers.

Disabling file system redirection affects only operations made by the current thread. Some functions, such as CreateProcessAsUser, do work on another thread which is not affected by the state of file system redirection in the calling thread.

Example Code [C++]

The following example uses Wow64DisableWow64FsRedirection to disable file system redirection so that a 32-bit application that is running under WOW64 can open the 64-bit version of Notepad.exe in %SystemRoot%\System32 instead of being redirected to the 32-bit version in %SystemRoot%\SysWOW64.

 #define _WIN32_WINNT 0x0501
#include <Windows.h>

    PVOID OldValue;
    HANDLE hFile = INVALID_HANDLE_VALUE;

    BOOL bRet = Wow64DisableWow64FsRedirection (&OldValue);

    if (bRet == TRUE) 
    {
        // Open a file
        
        hFile = CreateFile(TEXT("C:\\Windows\\System32\\Notepad.exe"),
            GENERIC_READ,
            FILE_SHARE_READ,
            NULL,
            OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL,
            NULL);

        // Restore the previous WOW64 file system redirection value.
 
        Wow64RevertWow64FsRedirection (OldValue);
    }
    
    if( INVALID_HANDLE_VALUE != hFile )  
    {
        // Use the file handle
    }

Requirements

Client Requires Windows Vista or Windows XP Professional x64 Edition.
Server Requires Windows Server 2008 or Windows Server 2003 SP1.
Header

Declared in WinBase.h; include Windows.h.

Library

Use Kernel32.lib.

DLL

Requires Kernel32.dll.

See Also

File Management Functions
File System Redirector
Wow64EnableWow64FsRedirection
Wow64RevertWow64FsRedirection


Send comments about this topic to Microsoft

Build date: 6/19/2008

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content      
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker