我有一个32位进程,可以在32位或64位Windows中运行.因此,自然地,如果进程试图访问文件c:\windows\system32\file.ext,它将被重定向到c:\windows\SysWOW64\file.ext。到目前为止还不错-我不想取消重定向。
我的问题是,我的进程实际上并不是access文件--而是采用它的路径,将其写入文本文件,我希望该文本文件在64位系统上读取SysWOW64,在32位系统上读取system32。我怎么能这么做?
发布于 2010-08-22 12:15:47
以下代码将返回正确的系统目录( system 32\syswow64):
[DllImport("shell32.dll")]
public static extern bool SHGetSpecialFolderPath(
IntPtr hwndOwner, [Out]StringBuilder lpszPath, int nFolder, bool fCreate
);
public static string GetSystemDirectory()
{
StringBuilder path = new StringBuilder(260);
NativeMethods.SHGetSpecialFolderPath(IntPtr.Zero, path, 0x0029, false);
return path.ToString();
}在x86上,您将在X64上得到%windir%\System32 32,您将得到%windir%\SysWow64 64。
希望这是有帮助的
发布于 2013-01-11 15:25:27
System32 C:\ Windows \ System 32 Windows系统文件夹(系统目录)用于64位文件SysWOW64 C:\SysWOW64\SysWOW64 64 Windows系统文件夹(系统目录)用于32位文件程序文件C:\Program文件夹用于64位程序文件程序文件(x86) C:\Program (x86)文件夹用于32位程序文件
https://stackoverflow.com/questions/3094520
复制相似问题