為什麼會有2個notepad.exe

來源:互聯網
上載者:User

為什麼會有2個notepad.exe

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檔案的方式比硬式編碼會更具有相容性。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.