为什么会有2个notepad.exe

欢迎转载!转载时请注明出处:http://blog.csdn.net/nfer_zhuang/article/details/43447895

原文出处:Why are there two copies of Notepad?

原文不长,直接贴在下面,英文OK的请直接看原文:

You may have noticed that there's a copy of Notepad in %windir%\notepad.exe and another in %windir%\system32\notepad.exe. Why two?

Compatibility, of course.

Windows 3.0 put Notepad in the Windows directory.Windows NT put it in the System32 directory.

Notepad is perhaps the most commonly hardcoded program in Windows.many Setup programs use it to view the Readme file,and you can use your imagination to come up with other places where a program or batch file or printed instructions will hard-code the path to Notepad.

In order to be compatible with programs designed for Windows 95, there needs to be a copy of Notepad in the Windows directory.And in order to be compatible with programs designed forWindows NT, there also needs to be a copy in theSystem32 directory.

And now that Notepad exists in both places,new programs have a choice of Notepads,and since there is no clear winner,half of them will choose the one in the Windows directoryand half will choose the one in the System32 directory,thereby ensuring the continued existence of two copiesof Notepad for years to come.

翻译如下:

也许你已经注意到了,在%windir%\目录和%windir%\system32\目录下各有一个名为notepad.exe的可执行程序。为什么会存在两个notepad.exe程序呢?

兼容性,必然是这个原因。

Windows 3.0是把notepad.exe放到了%windir%\目录,而Windows NT则把notepad.exe放到了%windir%\system32\目录。

Notepad也许是Windows系统下最通用的采用硬编码(译者注:此处的硬编码应该指的是Notepad程序的路径)的的程序。很多安装程序都是通过Notepad来显示Readme文件的,当然你可以用任何你想像到的方法,如一个单独的程序、一个脚本或者一个可打印的操作说明等等来给出Notepad程序的路径。

为了兼容那些为Windows 95设计的程序,那么必须在%windir%\目录下有一份Notepad程序的拷贝;而为了兼容那些为Windows NT设计的程序,在%windir%\system32\目录下也必须有一份Notepad程序的拷贝。

因此,目前的结果就是,在这两个地方都有一份Notepad的程序,新开发的程序在使用Notepad则可以自有选择。而且使用这两个路径没有一个明确的胜出者,一半选择%windir%\目录,另一半选择%windir%\system32\目录,而系统会继续保证这两个目录下的存在Notepad程序。

备注:

在原帖下还有一些回复也很精彩,摘抄如下:

Adam 28 Mar 2006 10:16 AM

Hmmmm.....on NTFS are they both hard links to the same file?
(More importantly, how could I get explorer to tell you this? What's the windows equivalent of `ls -i`?)

在NTFS文件系统下,这两个目录下的文件都是硬连接到同一个文件,而且答主怎么会告诉你,使用`ls -i`可以打印出文件的索引。

在我的电脑上,这两个文件的索引如下:

Eyal 28 Mar 2006 10:23 AM

I'd say the stupid part here was the decision to put notepad in different places in win3.0 and winNT.

是的,我也赞同Eyal的观点。

Phylyp  28 Mar 2006 10:50 AM

As Brian mentioned, a smart app shouldn't have to worry too much about *where* notepad is. The default path on Windows 2000 and XP has %SystemRoot%\system32 and then %SystemRoot%, so it would pick one of the notepads.
Another option would be to run "start yourtextfile.txt", which will launch the text file in the application handler for .txt files.

Phylyp认为一个聪明的程序应该会尝试先在%windir%\目录下找一下,然后再在%windir%\system32\目录下找找,然后打开找到的notepad.exe程序。还有一种做法,是使用start命令来打开txt文件,然后由系统来觉得具体使用什么文件来处理.txt文件。

确实,使用start命令打开.txt文件的方式比硬编码的会更具有兼容性。


猜你喜欢

转载自blog.csdn.net/nfer_cn/article/details/43447895