我想知道我们什么时候需要把一个文件放在

C:\Windows\ system32或C:\Windows\SysWOW64,在64位windows系统上。

我有两个DLL,一个32位,一个64位。

逻辑上,我认为我应该将32位DLL放在C:\Windows\System32下,而64位DLL放在C:\Windows\ syswow64下。

令我惊讶的是,情况正好相反!32位DLL进入C:\Windows\SysWOW64, 64位DLL进入C:\Windows\ system32。

非常令人困惑。背后的原因是什么?


当前回答

System32 is where Windows historically placed all 32bit DLLs, and System was for the 16bit DLLs. When microsoft created the 64 bit OS, everyone I know of expected the files to reside under System64, but Microsoft decided it made more sense to put 64bit files under System32. The only reasoning I have been able to find, is that they wanted everything that was 32bit to work in a 64bit Windows w/o having to change anything in the programs -- just recompile, and it's done. The way they solved this, so that 32bit applications could still run, was to create a 32bit windows subsystem called Windows32 On Windows64. As such, the acronym SysWOW64 was created for the System directory of the 32bit subsystem. The Sys is short for System, and WOW64 is short for Windows32OnWindows64. Since windows 16 is already segregated from Windows 32, there was no need for a Windows 16 On Windows 64 equivalence. Within the 32bit subsystem, when a program goes to use files from the system32 directory, they actually get the files from the SysWOW64 directory. But the process is flawed.

这是一个可怕的设计。根据我的经验,为了编写64位应用程序,我必须做更多的更改,简单地将System32目录更改为读取System64将是一个非常小的更改,而且是预编译器指令打算处理的。

其他回答

我相信其目的是重命名System32,但是许多应用程序都为该路径硬编码,因此不可能删除它。

SysWoW64并不是为64位系统的dll设计的,它实际上有点像“Windows64上的Windows”,这意味着你需要在64位窗口上运行32位应用程序。

这篇文章解释了一点:

Windows x64有一个包含64位dll的目录System32(原文如此!) 因此比特位为64的本机进程在以下位置找到“它们的”dll 在System32文件夹中。第二个目录, SysWOW64,包含32位的dll。文件系统重定向器可以 为32位进程隐藏真实System32目录的魔力 并在System32的名称下显示SysWOW64。

如果您谈论的是安装程序,您真的不应该硬编码系统文件夹的路径。相反,根据您的安装程序是否运行在模拟层上,让Windows为您处理它。

System32 is where Windows historically placed all 32bit DLLs, and System was for the 16bit DLLs. When microsoft created the 64 bit OS, everyone I know of expected the files to reside under System64, but Microsoft decided it made more sense to put 64bit files under System32. The only reasoning I have been able to find, is that they wanted everything that was 32bit to work in a 64bit Windows w/o having to change anything in the programs -- just recompile, and it's done. The way they solved this, so that 32bit applications could still run, was to create a 32bit windows subsystem called Windows32 On Windows64. As such, the acronym SysWOW64 was created for the System directory of the 32bit subsystem. The Sys is short for System, and WOW64 is short for Windows32OnWindows64. Since windows 16 is already segregated from Windows 32, there was no need for a Windows 16 On Windows 64 equivalence. Within the 32bit subsystem, when a program goes to use files from the system32 directory, they actually get the files from the SysWOW64 directory. But the process is flawed.

这是一个可怕的设计。根据我的经验,为了编写64位应用程序,我必须做更多的更改,简单地将System32目录更改为读取System64将是一个非常小的更改,而且是预编译器指令打算处理的。

我应该补充:你不应该把你的dll文件放在\system32\无论如何!修改你的代码,修改你的安装程序…为你的比特找一个不是在c:\windows\下的地方

例如,你的安装程序把你的dll放入:

\program files\<your app dir>\

or

\program files\common files\<your app name>\

(注意:你实际做到这一点的方法是使用环境var: %ProgramFiles% or %ProgramFiles(x86)%来查找ProgramFiles是....你不假设它是c:\program files\ ....)

然后设置一个注册表标签:

HKLM\software\<your app name>
-- dllLocation

使用dll的代码读取注册表,然后动态链接到该位置的dll。

以上是明智的做法。

不要将自己的dll或第三方dll安装到\system32\或\syswow64中。如果你必须静态加载,你把你的dll放在你的exe目录下(在那里可以找到它们)。如果你不能预测exe的目录(例如,其他exe将调用你的dll),你可能不得不把你的dll目录放入搜索路径(避免这一点,如果在所有poss!)

system32和syswow64是Windows提供的文件…其他人的文件都不行。人们养成把东西放在那里的坏习惯的唯一原因是,它总是在搜索路径中,许多应用程序/模块使用静态链接。(所以,如果你真的认真对待它,真正的罪过是静态链接——这是原生代码和托管代码的罪过——总是总是总是动态链接!)

其他人已经很好地解释了这个荒谬的难题……我认为克里斯·霍夫曼做得更好:https://www.howtogeek.com/326509/whats-the-difference-between-the-system32-and-syswow64-folders-in-windows/

我有两个想法:

We all make stupid short-sighted mistakes in life. When Microsoft named their (at the time) Win32 DLL directory "System32", it made sense at the time ... they just didn't take into consideration what would happen if/when a 64-bit (or 128-bit) version of their OS got developed later - and the massive backward compatibility issue such a directory name would cause. Hindsight is always 20-20, so I can't really blame them (too much) for such a mistake. ...HOWEVER... When Microsoft did later develop their 64-bit operating system, even with the benefit of hindsight, why oh why would they make not only the exact same short-sighted mistake AGAIN but make it even worse by PURPOSEFULLY giving it such a misleading name?!? Shame on them!!! Why not AT LEAST actually name the directory "SysWin32OnWin64" to avoid confusion?!? And what happens when they eventually produce a 128-bit OS ... then where are they going to put their 32-bit, 64-bit, and 128-bit DLLs?!? All of this logic still seems completely flawed to me. On 32-bit versions of Windows, System32 contains 32-bit DLLs; on 64-bit versions of Windows, System32 contains 64-bit DLLs ... so that developers wouldn't have to make code changes, correct? The problem with this logic is that those developers are either now making 64-bit apps needing 64-bit DLLs or they're making 32-bit apps needing 32-bit DLLs ... either way, aren't they still screwed? I mean, if they're still making a 32-bit app, for it to now run on a 64-bit Windows, they'll now need to make a code change to find/reference the same ol' 32-bit DLL they used before (now located in SysWOW64). Or, if they're working on a 64-bit app, they're going to need to re-write their old app for the new OS anyway ... so a recompile/rebuild was going to be needed anyway!!!

微软有时会伤害我。

遇到同样的问题,我研究了几分钟。

我被教导使用Windows 3.1和DOS,还记得那些日子吗?在我严格使用Macintosh电脑一段时间后不久,在买了一台x64位电脑后,我又开始转向Windows。

这些变化背后有实际的原因(有些人会说是历史意义),这对程序员继续他们的工作是必要的。

上面提到了大部分变化:

Program Files vs Program Files (x86) In the beginning the 16/86bit files were written on, '86' Intel processors. System32 really means System64 (on 64-bit Windows) When developers first started working with Windows7, there were several compatibility issues where other applications where stored. SysWOW64 really means SysWOW32 Essentially, in plain english, it means 'Windows on Windows within a 64-bit machine'. Each folder is indicating where the DLLs are located for applications it they wish to use them.

这里有两个链接,上面有你需要的所有基本信息:

MSDN文件系统重定向器 SysWow64解释

希望这能把事情弄清楚!