国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

給windows服務添加描述

2024-07-21 02:16:05
字體:
來源:轉載
供稿:網友

  最近寫了個windows服務(windows services),安裝了以后,覺得和已有的windows服務不一樣。為什么?我的缺少描述,中間一欄是空的。

  再看.net的servicebase類沒有添加描述的屬性。

  public class projectinstaller : system.configuration.install.installer中也沒有什么屬性來添加。從網搜了后才知道要重載projectinstaller 的install和uninstall虛方法。其實重寫這些虛方法就是為了在注冊表相應服務中加一個鍵值"description",其值填為相應的描述就可以了。

 public override void install(idictionary stateserver)
  {
   microsoft.win32.registrykey system,
       service,
       config;

   try
   {
    //let the project installer do its job
    base.install(stateserver);
    system = microsoft.win32.registry.localmachine.opensubkey("system").opensubkey("currentcontrolset").opensubkey("services");

    service = system.opensubkey(this.serviceinstaller1.servicename, true);

    service.setvalue("description", "服務描述");

   //添加額外的鍵
    config = service.createsubkey("additionalinformation");
   }
   catch(exception e)
   {  

   }
  }
  public override void uninstall(idictionary stateserver)
  {
   microsoft.win32.registrykey system,
    currentcontrolset,
    services,
    service;

   try
   {
        system = microsoft.win32.registry.localmachine.opensubkey("system");
    currentcontrolset = system.opensubkey("currentcontrolset");
    services = currentcontrolset.opensubkey("services");
    service = services.opensubkey(this.serviceinstaller1.servicename, true);
       //刪除額外的鍵
    service.deletesubkeytree("additionalinformation");
    //...
   }
   catch(exception e)
   {
      }
   finally
   {
    base.uninstall(stateserver);
   }
  }

注意這些代碼是在projectinstaller 文件中的。

也許有更好的辦法,望大家指教。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 化州市| 邻水| 台湾省| 涟源市| 翼城县| 天全县| 子长县| 沅陵县| 莱西市| 乐亭县| 水城县| 天长市| 城固县| 铜川市| 行唐县| 津市市| 霍城县| 绍兴市| 广汉市| 康定县| 昌都县| 小金县| 大田县| 诸暨市| 彰化市| 刚察县| 汕头市| 建阳市| 三原县| 新沂市| 罗江县| 贞丰县| 尉犁县| 苏州市| 清流县| 嘉善县| 龙江县| 五寨县| 两当县| 林周县| 万载县|