使用32位应用程序获取syswow64目录 [英] Getting syswow64 directory using 32-bit application
问题描述
我正在尝试在系统目录中找到一个文件。
问题是当使用
Environment.SystemDirectory
在x64机器上,我仍然收到System32目录,而不是Systemwow64目录。
我需要在x86机器上获取System32目录,而x64上的SystemWow64目录
任何想法?
编辑:
要找到SysWow64,我使用的是GetSystemWow64Directory。 (更多信息,请参见: pinvoke
请注意,在非x64机器上 - 结果为'0'
希望这有助于某人
使用 SHGetSpecialFolderPath
function:
[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()
}
将在x86上返回 System32
,x64上的 SysWow64
I'm trying to find a file inside the system directory. The problem is that when using
Environment.SystemDirectory
On a x64 machine, i'm still getting the System32 directory, instead of the Systemwow64 directory.
I need to get the "System32" directory on x86 machines, and "SystemWow64" directory on x64
Any ideas?
EDIT: To find the SysWow64 i'm using the "GetSystemWow64Directory". (more information here: pinvoke Notice that on non-x64 machines - result is '0'. Hope this helps someone
Using the SHGetSpecialFolderPath
function:
[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()
}
Will return System32
on x86, and SysWow64
on x64
这篇关于使用32位应用程序获取syswow64目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!