資源描述:
《C#設(shè)置安裝完成啟動(dòng)程序》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
1、c#安裝部署完成后自動(dòng)啟動(dòng)程序??2010-07-0413:49:23
2、??分類:?C#安裝布暑
3、舉報(bào)
4、字號(hào)?訂閱1.新建一個(gè)空的項(xiàng)目InstallCompenent,步驟為:解決方案->右鍵添加->新建項(xiàng)目->選擇"空項(xiàng)目"->輸入名稱"InstallCompenent"->確定,完成項(xiàng)目的添加.2.在InstallCompenent項(xiàng)目中右鍵->添加->新建項(xiàng)->選擇安裝程序類->輸入名稱"Installer",完成installer類的添加.修改代碼為:///???///功能是
5、做安裝項(xiàng)目主項(xiàng)目輸出???///實(shí)現(xiàn)安裝過(guò)程中的一些操作???///如:安裝完成后啟動(dòng)項(xiàng)目???///???[RunInstaller(true)]???publicpartialclassInstaller:Installer???{???????///???????///應(yīng)用程序入口???????///???????publicstaticvoidMain()???????{???????}???????///??????
6、?///構(gòu)造函數(shù)???????///???????publicECSuitsInstaller()???????{???????????InitializeComponent();???????}???????///???????///重寫安裝完成后函數(shù)???????///實(shí)現(xiàn)安裝完成后自動(dòng)啟動(dòng)已安裝的程序???????///???????///???????protectedov
7、erridevoidOnAfterInstall(IDictionarysavedState)???????{???????????base.OnAfterInstall(savedState);???????????Assemblyasm=Assembly.GetExecutingAssembly();???????????stringpath=asm.Location.Remove(asm.Location.LastIndexOf("\"))+"\";???????????System.Dia
8、gnostics.Process.Start(path+"\ECSuits.exe");???????}???????///???????///重寫安裝過(guò)程方法???????///???????///???????publicoverridevoidInstall(IDictionarystateSaver)???????{???????????base.Install(stateSaver);??
9、?????}???????///???????///重寫安裝之前方法???????///???????///???????protectedoverridevoidOnBeforeInstall(IDictionarysavedState)???????{???????????base.OnBeforeInstall(savedState);???????}???????///???
10、????///重寫卸載方法???????///???????///???????publicoverridevoidUninstall(IDictionarysavedState)???????{???????????base.Uninstall(savedState);???????}???????///???????///重寫回滾方法???????///???????///11、aramname="savedState">???????publicoverridevoidRollback(IDictionarysavedState)???????{???????????base.Rollback(savedState);???????}????}3.在安裝項(xiàng)目中右鍵->添加項(xiàng)目輸出->選擇"項(xiàng)目"->InstallCompenent.完成主輸出項(xiàng)目的添加.4.打開自定義操作編輯器,在安裝->右鍵->添加自定義操作