熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Delphi編程 >> 正文

為Delphi編寫的屏幕保護程序增加描述

2022-06-13   來源: Delphi編程 

  雖說屏幕保護程序只是個相對特殊的exe(會接受/C/P/S等啟動參數具體可見諸多博文在此不贅述)但是卻讓一個小小的描述卡住了

  我們知道作為屏幕保護程序安裝後會在系統的顯示對話框的列表裡出現而進而我們發現現有的屏幕保護程序顯示的並不是文件名而是一行描述而使用Delphi編寫的exe卻無法具備這個特性

  向搜索引擎尋求幫助後得到了如下的描述

  You can define the text that will appear in the Control Panel Desktop list of screen savers by adding a {$D text} directive to the project source file The $D directive inserts the given text into the module description entry of the executable file For the Control Panel to recognize the text you must start with the term SCRNSAVE followed by your description

  Select Project Source from the Delphi View menu so you can edit the source file Beneath the directive {$R *RES} add the following line

  {$D SCRNSAVE Spheres Screen Saver}The text Spheres Screen Saver will appear in the Control Panel list of available screen savers when we complete the project

  ()

  大意是在dpr文件中寫入{$D SCRNSAVE [要顯示的描述]}就可以在編譯之後的exe內加入屏幕保護程序描述字符

  而就是因為這個僅有的說明(貌似瘋狂的轉載並不是好事連已經無效的方法都被這樣流傳著)讓我走了很多彎路以這個說明為前提我險些否定了自己的工作

  直到一天研究無果後我決定另辟蹊徑既然裡面說了是字符串那麼估計應該在程序內能找到

  於是我將系統內置的屏幕保護程序用eXeScope打開赫然發現了新大陸

  在字符串節點下key為的值就是SCRNSAVE +空格+屏幕保護程序描述字符串

  那麼那個{$D text}是什麼呢?進而通過仔細查詢發現這個關鍵字是生成應用程序描述的而非字符串資源(找到這個說明後才猛然醒悟為啥不深究一下這個$D呢都怪自己太不自信了)

  既然知道了描述字符串的規則那就動手搞定

  新建一個rc文件設置如下格式

  stringtable

  begin

   SCRNSAVE [要顯示的描述字符串]

  End


From:http://tw.wingwit.com/Article/program/Delphi/201311/24688.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.