Wow64DisableWow64FsRedirection 函式 (wow64apiset.h)
停用呼叫線程的文件系統重新導向。 預設會啟用檔案系統重新導向。
BOOL Wow64DisableWow64FsRedirection(
[out] PVOID *OldValue
);
[out] OldValue
WOW64 檔案系統重新導向值。 系統會使用此參數來儲存還原 (重新啟用) 檔案系統重新導向所需的資訊。
如果函式成功,則傳回值是非零值。
如果此函式失敗,則傳回值為零。 若要取得擴充的錯誤資訊,請呼叫 GetLastError。
此函式適用於想要取得原生 system32 目錄存取權的 32 位應用程式。 根據預設,會啟用 WOW64 檔案系統重新導向。
Wow64DisableWow64FsRedirection/Wow64RevertWow64FsRedirection 函式配對是 Wow64EnableWow64FsRedirection 函式功能的取代專案。
若要還原文件系統重新導向,請呼叫 Wow64RevertWow64FsRedirection 函式 。 對 Wow64DisableWow64FsRedirection 函式的每個成功呼叫都必須具有 Wow64RevertWow64FsRedirection 函式的相符呼叫。 這可確保重新導向已啟用,並釋放相關聯的系統資源。
在 Windows 8 和 Windows Server 2012 中,下列技術支援此函式。
技術 | 支援 |
---|---|
伺服器消息塊 (SMB) 3.0 通訊協定 | No |
SMB 3.0 透明故障轉移 (TFO) | No |
具有向外延展檔案共用的SMB 3.0 (SO) | No |
叢集共用磁碟區文件系統 (CsvFS) | Yes |
彈性檔案系統 (ReFS) | 否 |
下列範例使用 Wow64DisableWow64FsRedirection 停用文件系統重新導向,讓在 WOW64 下執行的 32 位應用程式可以開啟 %SystemRoot%\System32 中 64 位版本的 Notepad.exe,而不是重新導向至 %SystemRoot%\SysWOW64 中的 32 位版本。
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0501
#ifdef NTDDI_VERSION
#undef NTDDI_VERSION
#endif
#define NTDDI_VERSION 0x05010000
#include <Windows.h>
void main()
{
HANDLE hFile = INVALID_HANDLE_VALUE;
PVOID OldValue = NULL;
// Disable redirection immediately prior to the native API
// function call.
if( Wow64DisableWow64FsRedirection(&OldValue) )
{
// Any function calls in this block of code should be as concise
// and as simple as possible to avoid unintended results.
hFile = CreateFile(TEXT("C:\\Windows\\System32\\Notepad.exe"),
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
// Immediately re-enable redirection. Note that any resources
// associated with OldValue are cleaned up by this call.
if ( FALSE == Wow64RevertWow64FsRedirection(OldValue) )
{
// Failure to re-enable redirection should be considered
// a critical failure and execution aborted.
return;
}
}
// The handle, if valid, now can be used as usual, and without
// leaving redirection disabled.
if( INVALID_HANDLE_VALUE != hFile )
{
// Use the file handle
}
}
需求 | 值 |
---|---|
最低支援的用戶端 | Windows Vista、Windows XP Professional x64 Edition [僅限傳統型應用程式] |
最低支援的伺服器 | Windows Server 2008、Windows Server 2003 SP1 [僅限傳統型應用程式] |
目標平台 | Windows |
標頭 | wow64apiset.h (包含 Windows.h) |
程式庫 | Kernel32.lib |
DLL | Kernel32.dll |