首先,新建一個工程:File->New->Common->InstallScript Project 添入你的工程名,去掉Create project file in 'Project Name' subfolder 前面的對鉤,選擇“OK ”。
進入Project assistant 界面。單擊“- - - > ”按鈕。根據需要填寫公司名、應用程序名。
添加組件,這裏默認,點下一步。
選擇上一步的組件,根據需要選擇你要最終將文件拷貝到的地方。如:我需要將我的程序安裝到“C:/Program Files/廣州升和電器設備有限公司/高考監控軟件/xxx.exe"則選擇Program Fiels 點右鍵選擇:New Folder 將文件夾重命名爲:廣州升和電器設備有限公司 ,右鍵點擊“廣州升和電器設備有限公司”選New Folder ,重命名爲:高考監控軟件。選擇“高考監控軟件”文件夾,點ADD FILES 添入你的應用程序等。如下圖:
添加快捷鍵:選擇NEW按鈕,出現選擇對話框,選擇剛纔添入的exe文件。可以對它進行重命名。
下一步,出現詢問註冊對話框,這裏缺省,下一步。
詢問你的打包程序所出現的對話框:如:閱讀協議、公司/用戶名、安裝路徑等。
再下來是選擇安裝語言,選擇簡體中文(如果安裝了的話),你會發現默認的英文是不能不選的,怎麼修改,後面有介紹。
選擇最後安裝程序生成形式,這裏選CD-ROM。運行Build Installations。一個簡單的安裝程序就出來了。
下面講幾個修改:
1.修改語言。選擇Installation Designer選項卡,選擇General Information 在中間界面會看到String Table裏出現了簡體中文和英文。默認爲英文。在簡體中文點右鍵,選make define。然後在回到Project Assistant的選擇安裝語言界面將英文前面的對鉤去掉。
2.安裝時提示安裝.NET2.0。選擇Installation Designer- - - >Support Files/Billboards- - - >Language Independent.在右邊工作區中點右鍵選Insert Files Ins 將dotnetfx.exe加入,然後在Install Script的Dlg_SdFeatureTree:中修改代碼:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath;
szTitle = "";
szMsg = "";
szFeatures = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
//{{IS_SCRIPT_TAG(Dlg_SdFeatureTree)
nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel );
//}}IS_SCRIPT_TAG(Dlg_SdFeatureTree)
if (nResult = BACK) goto Dlg_SdAskDestPath;
endif;
MessageBox ("接下來系統將安裝.NET2.0,如果系統在安裝的過程中提示已經安裝則取消即可。", INFORMATION);
szJDK = SUPPORTDIR ^ "dotnetfx.exe";
if (LaunchAppAndWait (szJDK, "", WAIT) < 0) then
MessageBox ("不能加載程序 .NET2.0。",SEVERE);
endif;
3.在安裝程序複製文件到指定目錄後,修改完成對話框,要求實現詢問時候查看自述文件和運行程序功能。首先按照添加dotetfx.exe的方法加入文本文件ReadMe.txt。加入函數OnFirstUIAfter()
STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2,szProductName;
NUMBER bvOpt1, bvOpt2;
NUMBER bShowUpdateServiceDlg;
begin
ShowObjWizardPages(NEXT);
szProductName = "高考系統監控軟件";
SdProductName (szProductName);
szTitle = "高考系統監控軟件安裝程序";
szMsg1 = "%P 安裝程序已經完成. " +
"選擇您想要的服務.";
szMsg2 = "單擊"完成"完成%P安裝程序.";
szOpt1 = "查看自述文件.";
szOpt2 = "運行%P.";
bShowUpdateServiceDlg = FALSE;
//{{IS_SCRIPT_TAG(Dlg_SdDinishEx)
if ( BATCH_INSTALL ) then
SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
else
// If the update service is enabled, show finish dialog that includes
// update check option.
if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then
if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then
// Don't check for updates in silent mode.
if( MODE != SILENTMODE ) then
UpdateServiceCheckForUpdates( "", FALSE );
endif;
endif;
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
if (bvOpt1) then // Display the read me file.
LaunchAppAndWait (NOTEPAD, READMEFILE, LAAW_OPTION_WAIT);
endif ;
if (bvOpt2) then
LaunchApp (TARGETDIR ^ "CustormSystem.exe","");
// szTitle=TARGETDIR;
/* SprintfBox (INFORMATION, szTitle, "Launch %s here.",
szProductName); */
endif;
endif;
endif;
//}}IS_SCRIPT_TAG(Dlg_SdDinishEx)
end;
工程到此也接近尾聲了。