我试图在系统目录中找到一个文件。问题是当使用
Environment.SystemDirectory在x64机器上,我仍然得到System32目录,而不是Systemwow64目录。
我需要获取x86机器上的"SystemWow64“目录和x64上的”SystemWow64“目录。
有什么想法吗?
编辑:查找我正在使用的"GetSystemWow64Directory“的SysWow64。(这里有更多信息:[医] pinvoke注意到,在非x64机器上,结果是'0‘。希望这能帮到别人
发布于 2010-09-02 06:39:54
使用SHGetSpecialFolderPath函数:
[DllImport("shell32.dll")]
public static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [Out]StringBuilder lpszPath, int nFolder, bool fCreate);
string GetSystemDirectory()
{
StringBuilder path = new StringBuilder(260);
SHGetSpecialFolderPath(IntPtr.Zero,path,0x0029,false);
return path.ToString()
}将返回System32 on x86,SysWow64返回x64
发布于 2010-08-22 09:37:13
使用Environment.GetFolderPath(Environment.SpecialFolder.SystemX86)代替。
发布于 2010-08-22 09:39:48
您的32位程序认为System32实际上是SysWOW64 --不要编写32位应用程序来明确了解64位,这就是WOW64重定向的目的。
https://stackoverflow.com/questions/3540930
复制相似问题