Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Disabling Windows file system redirection on a CFileDialog

0.00/5 (No votes)
24 Apr 2010 1  
Introduction...

Introduction


Windows on Windows 64-bit (WOW64) provides file system redirection. In a 64-bit version of Windows Server 2003 or of Windows XP, the %WinDir%\System32 folder is reserved for 64-bit applications. When a 32-bit application tries to access the System32 folder, access is redirected to the following folder:
%WinDir%\SysWOW64
By default, file system redirection is enabled.

Background


You can use the following functions to control file system redirection:

  • Wow64DisableWow64FsRedirection
  • Wow64EnableWow64FsRedirection
  • Wow64RevertWow64FsRedirection

The problem is that it is disabled on the current thread. Hence I faced a problem where I could not use CFileDialog Box to access the System32 folder. I searched on the net and could not find an article, so here goes my first article :)

Using the Code


You should derive a class from CFileDialog. And in the constructor, disable the flags and enable it back again in the destructor :)

class CFileDialogEx :	public CFileDialog
{
public:
	CFileDialogEx(void);
	~CFileDialogEx(void);
private:
	PVOID OldValue;
}; 

CFileDialogEx::CFileDialogEx(void):CFileDialog(true)
{
	Wow64DisableWow64FsRedirection(&OldValue);
}

CFileDialogEx::~CFileDialogEx(void)
{
	Wow64RevertWow64FsRedirection(OldValue);
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here