zoukankan      html  css  js  c++  java
  • 以前编写的inno setup脚本,涵盖了自定义安装界面,调用dll等等应用 (转)

    以前编写的inno setup脚本,涵盖了自定义安装界面,调用dll等等应用 (转)

    1. ; Script generated by the Inno Setup 脚本向导.  
    2. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!  
    3.   
    4. ; 为1的时候表示定义成试用版本  
    5. #define VERSION_TYPE ReadIni('Setup.ini', 'SetupType', 'type', '0')  
    6.   
    7. #if VERSION_TYPE == "2"  
    8.     #define LIVE_VERSION  
    9.     #define MyAppName "流媒体系统(PMS)"  
    10.     #define MyAppId "1954A698-2322-46F1-B732-8DDF96693DA5"  
    11.     #define MyOutputBaseFilename "live_server_setup"  
    12. #elif VERSION_TYPE == "1"  
    13.     #define VOD_VERSION  
    14.     #define MyAppName "流媒体系统(PMS)"  
    15.     #define MyAppId "DA255679-F103-4170-8B75-B9A7EF4CBC1B"  
    16.     #define MyOutputBaseFilename "vod_server_setup"  
    17. #else  
    18.     #define FULL_VERSION  
    19.     #define MyAppName "流媒体系统(PMS)"  
    20.     #define MyAppId "4AC618B5-8C69-4D47-918A-261AA895B6D7"  
    21.     #define MyOutputBaseFilename "full_server_setup"  
    22. #endif  
    23.   
    24. #define RegUrl "http://www.xxx.net"  
    25. #define MyAppVersion "1.0"  
    26. #define MyAppPublisher "XXX科技有限公司"  
    27. #define MyAppURL "http://www.xxx.net"  
    28. #define MyAppExeName "InstanceConfig.exe"  
    29.   
    30. [Setup]  
    31. ; NOTE: The value of AppId uniquely identifies this application.  
    32. ; Do not use the same AppId value in installers for other applications.  
    33. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)  
    34. AppId={{{#MyAppId}}  
    35. AppMutex={{{#MyAppId}}  
    36. AppName={#MyAppName}  
    37. AppVersion={#MyAppVersion}  
    38. AppPublisher={#MyAppPublisher}  
    39. AppPublisherURL={#MyAppURL}  
    40. AppSupportURL={#MyAppURL}  
    41. AppUpdatesURL={#MyAppURL}  
    42. DefaultDirName={pf}xxxmedia server  
    43. DefaultGroupName={#MyAppName}  
    44. AllowNoIcons=yes  
    45. LicenseFile=license.txt  
    46. OutputDir=output  
    47. OutputBaseFilename={#MyOutputBaseFilename}  
    48. SetupIconFile=setup.ico  
    49. Compression=lzma  
    50. SolidCompression=yes  
    51.   
    52. VersionInfoVersion={#MyAppVersion}  
    53. VersionInfoCompany={#MyAppPublisher}  
    54. VersionInfoCopyright=Copyright (C) 2010-2013  
    55. VersionInfoProductName={#MyAppName}  
    56. VersionInfoProductVersion={#MyAppVersion}  
    57.   
    58. [Languages]  
    59. Name: cn; MessagesFile: compiler:Languageschinese.isl  
    60.   
    61. [Files]  
    62. ; NOTE: Don't use "Flags: ignoreversion" on any shared system files  
    63. ; 用来检测安装程序中输入的注册码是否有效  
    64. Source: ..uild egister_help.dll; Flags: dontcopy  
    65. Source: ..uildlibeay32.dll; Flags: dontcopy  
    66. Source: ..uildvcredist2008_x86.exe; Flags: dontcopy  
    67.   
    68. #ifdef FULL_VERSION  
    69. Source: ..uildserver.conf; DestDir: {app}  
    70. Source: ..uildmedia_service.exe; DestDir: {app}  
    71. Source: ..uildlibmysql.dll; DestDir: {app}  
    72. Source: ..uildlibeay32.dll; DestDir: {app}  
    73. Source: ..uildzlib1.dll; DestDir: {app}  
    74. Source: ..uild egister_check.exe; DestDir: {app}  
    75. Source: ..uildQtCore4.dll; DestDir: {app}  
    76. Source: ..uildQtGui4.dll; DestDir: {app}  
    77. Source: ..uildmglobal.dll; DestDir: {app}  
    78. Source: ..uildmsvcp100.dll; DestDir: {app}  
    79. Source: ..uildmsvcr100.dll; DestDir: {app}  
    80. Source: ..uildinitconfig.exe; DestDir: {app}  
    81. Source: ..uildInstanceConfig.exe; DestDir: {app}  
    82. ;Source: ..uildphp-fpm.exe; DestDir: {app}  
    83. Source: ..uild管理统计页面.url; DestDir: {app}  
    84. Source: ..uild示例页面.url; DestDir: {app}  
    85.   
    86. Source: ..uildlaunchlist; DestDir: {app}  
    87. ;Source: ..uildphpcgi; DestDir: {app}  
    88.   
    89. Source: ..uildlighttpd.conf; DestDir: {app}lmplighttpdconf; Flags: ignoreversion  
    90. Source: ..uildmy.ini; DestDir: {app}lmpmysql; Flags: ignoreversion  
    91.   
    92. ; web服务器整套目录  
    93. Source: ..uildlmp*; DestDir: {app}lmp; Flags: recursesubdirs createallsubdirs  
    94. ; doc文档目录  
    95. Source: ..doc*; DestDir: {app}help; Flags: recursesubdirs createallsubdirs  
    96. ; 播放器相关目录  
    97. Source: ..uildswfs*; DestDir: {app}swfs; Flags: recursesubdirs createallsubdirs  
    98. ; 播放器SDK相关目录  
    99. Source: ..uildscriptlib*; DestDir: {app}scriptlib; Flags: recursesubdirs createallsubdirs  
    100.   
    101. #endif  
    102.   
    103. [Dirs]  
    104. Name: {app}videos  
    105.   
    106. [Tasks]  
    107. Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}  
    108.   
    109. [Icons]  
    110. Name: {group}sample示例页面; Filename: {app}示例页面.url  
    111.   
    112. Name: {group}help安装说明; Filename: {app}help安装说明.pdf  
    113. Name: {group}help功能说明; Filename: {app}help功能说明.pdf  
    114. Name: {group}help开发说明; Filename: {app}help开发说明.pdf  
    115. Name: {group}help配置说明; Filename: {app}help配置说明.pdf  
    116. Name: {group}help统计模块; Filename: {app}help统计模块.pdf  
    117.   
    118. Name: {group}流媒体系统(PMS)系统配置; Filename: {app}{#MyAppExeName}  
    119. Name: {group}{cm:UninstallProgram, PMS系统配置}; Filename: {uninstallexe}  
    120. Name: {group}流媒体系统(PMS)统计管理; Filename: {app}管理统计页面.url; IconFilename: {app}{#MyAppExeName};  
    121. Name: {commondesktop}流媒体系统(PMS)统计管理; Filename: {app}管理统计页面.url; Tasks: desktopicon; IconFilename: {app}{#MyAppExeName};  
    122. Name: {commondesktop}流媒体系统(PMS)系统配置; Filename: {app}{#MyAppExeName}; Tasks: desktopicon  
    123. Name: {commondesktop} 开启PMS服 务; Filename: {app}media_service.exe; Parameters: -r; IconFilename: {app}{#MyAppExeName}; Tasks: desktopicon  
    124. Name: {commondesktop} 停止PMS服 务; Filename: {app}media_service.exe; Parameters: -s; IconFilename: {app}{#MyAppExeName}; Tasks: desktopicon  
    125.   
    126. [Run]  
    127. ; 删除服务  
    128. Filename: {app}media_service.exe; Parameters: -u; Flags: runhidden  
    129. ; 安装服务  
    130. Filename: {app}media_service.exe; Parameters: -i; Flags: runhidden  
    131.   
    132. [UninstallRun]  
    133. ; 停止服务  
    134. Filename: {app}media_service.exe; Parameters: -s; Flags: runhidden  
    135. ; 删除服务  
    136. Filename: {app}media_service.exe; Parameters: -u; Flags: runhidden  
    137.   
    138. [CustomMessages]  
    139. Key_Form_Caption=注册向导  
    140. Key_Form_Description=将序列号提交给xxx以获取注册码  
    141. Key_Form_codeLabel_Caption0=序列号:  
    142. Key_Form_keyLabel_Caption0=注册码:  
    143.   
    144. Domain_Form_Caption=域名设置  
    145. Domain_Form_Description=配置当前服务器域名  
    146.   
    147. [Messages]  
    148. BeveledLabel=xxx网络科技  
    149.   
    150. [Code]  
    151. var  
    152.     codeLabel: TLabel;  
    153.     keyLabel: TLabel;  
    154.     key: TMemo;  
    155.     code: TMemo;  
    156.   keyPage: TWizardPage;  
    157.   domainEdit: TNewEdit;  
    158.   domainPage: TWizardPage;  
    159.   
    160. // 获取序列号  
    161. function getCode(szCode: PChar; inLen: Integer): Integer;  
    162. external 'getCode@files:register_help.dll,libeay32.dll,msvcr100.dll stdcall setuponly delayload loadwithalteredsearchpath';  
    163.   
    164. // 进行检查  
    165. function regCheck(const regKey: PChar): Boolean;  
    166. external 'regCheck@files:register_help.dll,libeay32.dll,msvcr100.dll stdcall setuponly delayload loadwithalteredsearchpath';  
    167.   
    168. // 进行注册  
    169. function regSave(const regKey, regPath: PChar): Boolean;  
    170. external 'regSave@files:register_help.dll,libeay32.dll,msvcr100.dll stdcall setuponly delayload loadwithalteredsearchpath';  
    171.   
    172. // 清理注册  
    173. procedure regClear(const regPath: PChar);  
    174. external 'regClear@files:register_help.dll,libeay32.dll,msvcr100.dll stdcall setuponly delayload loadwithalteredsearchpath';  
    175.   
    176. function OpenSCManager(const machine: LongInt; const dbName: LongInt;  access: Dword):LongInt;  
    177. external 'OpenSCManagerA@Advapi32.dll stdcall';  
    178.   
    179. function OpenService(svcMgr: LongInt; const svcName: pchar;  access: Dword):LongInt;  
    180. external 'OpenServiceA@Advapi32.dll stdcall';  
    181.   
    182. function CloseServiceHandle(svc: LongInt):Boolean;  
    183. external 'CloseServiceHandle@Advapi32.dll stdcall';  
    184.   
    185. ///判定服务是否存在  
    186. function  serviceExists(name: string): boolean;  
    187. var  
    188.     SvcMgr, Svc: LongInt;  
    189. begin  
    190.     Result := False;  
    191.     SvcMgr := OpenSCManager(0,0,1);  
    192.     if SvcMgr = 0 then Exit;  
    193.     Svc := OpenService(SvcMgr, PChar(name), 4);  
    194.     if Svc = 0 then  
    195.     begin  
    196.       CloseServiceHandle(SvcMgr);  
    197.       Exit;  
    198.     end;  
    199.     CloseServiceHandle(Svc);  
    200.     CloseServiceHandle(SvcMgr);  
    201.     Result := true;  
    202. end;  
    203.   
    204. ///停止服务  
    205. procedure stopService;  
    206. var  
    207.   ResultCode: Integer;  
    208. begin  
    209.   Exec(ExpandConstant('{tmp}media_service.exe'), '-s', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);  
    210. end;  
    211.   
    212. { Key_Form_ShouldSkipPage }  
    213.   
    214. function Key_Form_ShouldSkipPage(Page: TWizardPage): Boolean;  
    215. var  
    216.     codeStr: String;  
    217. begin  
    218.     SetLength(codeStr, 1024);  
    219.     getCode(PChar(codeStr), 1024);  
    220.     code.Text := codeStr;  
    221.     Result := False;  
    222. end;  
    223.   
    224. // 注册码编辑框改变事件  
    225. procedure Key_Form_KeyChange(Sender: TObject);  
    226. begin  
    227. // 检测注册码  
    228.     if regCheck(PChar(key.Text)) then  
    229.         WizardForm.NextButton.Enabled := True  
    230.     else  
    231.         WizardForm.NextButton.Enabled := False;  
    232. end;  
    233.   
    234. procedure RegURLLabelOnClick(Sender: TObject);  
    235. var  
    236.   ErrorCode: Integer;  
    237. begin  
    238.   ShellExec('open', ExpandConstant('{#RegURL}'), '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);  
    239. end;  
    240.   
    241. { Key_Form_CreatePage }  
    242. function Key_Form_CreatePage(PreviousPageId: Integer): Integer;  
    243. var  
    244.   URLLabel: TNewStaticText;  
    245. begin  
    246.     keyPage := CreateCustomPage(  
    247.               PreviousPageId,  
    248.               ExpandConstant('{cm:Key_Form_Caption}'),  
    249.               ExpandConstant('{cm:Key_Form_Description}')  
    250.           );  
    251.   
    252.   { codeLabel }  
    253.     codeLabel := TLabel.Create(keyPage);  
    254.     with codeLabel do  
    255.     begin  
    256.         Parent := keyPage.Surface;  
    257.         Caption := ExpandConstant('{cm:Key_Form_codeLabel_Caption0}');  
    258.         Left := ScaleX(0);  
    259.         Top := ScaleY(0);  
    260.         Width := ScaleX(40);  
    261.         Height := ScaleY(13);  
    262.     end;  
    263.   
    264.   { keyLabel }  
    265.     keyLabel := TLabel.Create(keyPage);  
    266.     with keyLabel do  
    267.     begin  
    268.         Parent := keyPage.Surface;  
    269.         Caption := ExpandConstant('{cm:Key_Form_keyLabel_Caption0}');  
    270.         Left := ScaleX(0);  
    271.         Top := ScaleY(82);  
    272.         Width := ScaleX(40);  
    273.         Height := ScaleY(13);  
    274.     end;  
    275.   
    276.   { key }  
    277.     key := TMemo.Create(keyPage);  
    278.     with key do  
    279.     begin  
    280.         Parent := keyPage.Surface;  
    281.         Left := ScaleX(0);  
    282.         Top := ScaleY(98);  
    283.         Width := ScaleX(410);  
    284.         Height := ScaleY(106);  
    285.         ScrollBars := ssVertical;  
    286.         TabOrder := 0;  
    287.     OnChange := @Key_Form_KeyChange;  
    288.     end;  
    289.   
    290.   { code }  
    291.     code := TMemo.Create(keyPage);  
    292.     with code do  
    293.     begin  
    294.         Parent := keyPage.Surface;  
    295.         Left := ScaleX(0);  
    296.         Top := ScaleY(16);  
    297.         Width := ScaleX(410);  
    298.         Height := ScaleY(60);  
    299.         ReadOnly := True;  
    300.         ScrollBars := ssVertical;  
    301.         TabOrder := 1;  
    302.     end;  
    303.   
    304.     with keyPage do  
    305.     begin  
    306.         OnShouldSkipPage := @Key_Form_ShouldSkipPage;  
    307.     end;  
    308.   
    309.     Result := keyPage.ID;  
    310.   
    311.   URLLabel := TNewStaticText.Create(keyPage);  
    312.   with URLLabel do  
    313.   begin  
    314.     Caption := '获取注册码';  
    315.     Cursor := crHand;  
    316.     OnClick := @RegURLLabelOnClick;  
    317.     Parent := keyPage.Surface;  
    318.     Font.Style := URLLabel.Font.Style + [fsUnderline];  
    319.     Font.Color := clBlue;  
    320.     Left := ScaleX(350);  
    321.     Top := ScaleY(210);  
    322.   end;  
    323. end;  
    324.   
    325. { 设置域名页面相关代码 }  
    326. procedure Domain_Form_EditChange(sender: TObject);  
    327. begin  
    328.   if domainEdit.Text = '' then  
    329.     WizardForm.NextButton.Enabled := False  
    330.   else  
    331.     WizardForm.NextButton.Enabled := True;  
    332. end;  
    333.   
    334. function Domain_Form_CreatePage(PreviousPageId: Integer): Integer;  
    335. var  
    336.   domainLabel: TNewStaticText;  
    337. begin  
    338.     domainPage := CreateCustomPage(  
    339.               PreviousPageId,  
    340.               ExpandConstant('{cm:Domain_Form_Caption}'),  
    341.               ExpandConstant('{cm:Domain_Form_Description}')  
    342.           );  
    343.   
    344.   domainLabel := TNewStaticText.Create(domainPage);  
    345.   with domainLabel do  
    346.   begin  
    347.     Parent := domainPage.Surface;  
    348.     Caption := '请确保输入的域名是有效的,并指向当前服务器IP,否则可以直接填写本机' + #13#10 + 'IP地址,或者保持默认值不变';  
    349.         Left := ScaleX(0);  
    350.         Top := ScaleY(60);  
    351.         Width := ScaleX(400);  
    352.         Height := ScaleY(28);  
    353.   end;  
    354.     
    355.   domainEdit := TNewEdit.Create(domainPage);  
    356.   with domainEdit do  
    357.   begin  
    358.     Parent := domainPage.Surface;  
    359.     Text := GetComputerNameString;  
    360.         Left := ScaleX(0);  
    361.         Top := ScaleY(90);  
    362.         Width := ScaleX(400);  
    363.         Height := ScaleY(13);  
    364.     OnChange := @Domain_Form_EditChange;  
    365.   end;   
    366. end;  
    367.   
    368. procedure URLLabelOnClick(Sender: TObject);  
    369. var  
    370.   ErrorCode: Integer;  
    371. begin  
    372.   ShellExec('open', ExpandConstant('{#MyAppURL}'), '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);  
    373. end;  
    374.   
    375. // 安装初始化  
    376. function InitializeSetup(): Boolean;  
    377. begin  
    378.   if serviceExists('MediaSrv') then  
    379.   begin //服务存在,先停止它  
    380.     if MsgBox('服务已经存在,要继续吗?', mbConfirmation, MB_YESNO) = IDNO then  
    381.     begin  
    382.       Result := False;  
    383.       Exit;  
    384.     end;  
    385.     ExtractTemporaryFile('media_service.exe');  
    386.     ExtractTemporaryFile('msvcr100.dll');  
    387.     ExtractTemporaryFile('msvcp100.dll');  
    388.     stopService;  
    389.   end;  
    390.     result := True;  
    391. end;  
    392.   
    393. procedure InitializeWizard();  
    394. var  
    395.   URLLabel: TNewStaticText;  
    396. begin  
    397.     Key_Form_CreatePage(wpSelectDir);  
    398.   Domain_Form_CreatePage(keyPage.ID);  
    399.   
    400.   URLLabel := TNewStaticText.Create(WizardForm);  
    401.   with URLLabel do  
    402.   begin  
    403.     Caption := ExpandConstant('{#MyAppURL}');  
    404.     Cursor := crHand;  
    405.     OnClick := @URLLabelOnClick;  
    406.     Parent := WizardForm;  
    407.     Font.Style := URLLabel.Font.Style + [fsUnderline];  
    408.     Font.Color := clBlue;  
    409.     Left := ScaleX(20);  
    410.     Top := WizardForm.ClientHeight - ScaleY(30);  
    411.   end;  
    412. end;  
    413.   
    414. // 页面切换事件  
    415. procedure CurPageChanged(CurPageID: Integer);  
    416. var  
    417.   ResultCode: Integer;  
    418.   file: String;  
    419.   buf: String;  
    420. begin  
    421.   WizardForm.BackButton.Enabled := True;  
    422.   
    423.   if CurPageID = keyPage.ID then  
    424.     WizardForm.NextButton.Enabled := False  
    425.   else if CurPageID = wpFinished then  
    426.   begin  
    427.     ///////////////////////////////////////////////////////////  
    428.     // 帮助设置HOST_NAME为用户设置的域名  
    429.     file := ExpandConstant('{app}lmphtdocssampleconfig.php');  
    430.     if LoadStringFromFile(file, buf) then  
    431.     begin  
    432.       StringChangeEx(buf, '%HOST_NAME%', domainEdit.Text, False);  
    433.       SaveStringToFile(file, buf, False);  
    434.     end;  
    435.   
    436.     file := ExpandConstant('{app}管理统计页面.url');  
    437.     if LoadStringFromFile(file, buf) then  
    438.     begin  
    439.       StringChangeEx(buf, '%HOST_NAME%', domainEdit.Text, False);  
    440.       SaveStringToFile(file, buf, False);  
    441.     end;  
    442.   
    443.     file := ExpandConstant('{app}示例页面.url');  
    444.     if LoadStringFromFile(file, buf) then  
    445.     begin  
    446.       StringChangeEx(buf, '%HOST_NAME%', domainEdit.Text, False);  
    447.       SaveStringToFile(file, buf, False);  
    448.     end;  
    449.     ///////////////////////////////////////////////////////////  
    450.   
    451.     // 禁用完成按钮  
    452.     WizardForm.NextButton.Enabled := False;  
    453.     // 正式写入注册文件  
    454.     regSave(PChar(key.Text), WizardDirValue);  
    455.     // 执行自动初始化  
    456.     Exec(ExpandConstant('{app}initconfig.exe'), '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);  
    457.     // 执行配置设置  
    458.     Exec(ExpandConstant('{app}InstanceConfig.exe'), '-r', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);  
    459.     // 启动服务  
    460.     Exec(ExpandConstant('{app}media_service.exe'), '-r', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);  
    461.     // 启用完成按钮  
    462.     WizardForm.NextButton.Enabled := True;  
    463.   end  
    464.   else if CurPageID = wpInstalling then  
    465.   begin  
    466.     // 安装运行时库  
    467.     ExtractTemporaryFile('vcredist2008_x86.exe');  
    468.     // 执行2008库安装  
    469.     Exec(ExpandConstant('{tmp}vcredist2008_x86.exe'), '/q', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);  
    470.   end  
    471.   else if CurPageID = domainPage.ID then  
    472.   begin  
    473.     WizardForm.BackButton.Enabled := False;  
    474.   end;  
    475. end;  
    476.   
    477. // 卸载  
    478. procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);  
    479. begin  
    480.   if CurUninstallStep = usUninstall then  
    481.   begin  
    482.     DeleteFile(ExpandConstant('{app}lsc'));  
    483.   end;  
    484. end;  
    485.   
    486. // 检查重启逻辑  
    487. function UninstallNeedRestart(): Boolean;  
    488. begin  
    489.   if serviceExists('MediaSrv') then  
    490.     result := True  
    491.   else  
    492.     result := False;  
    493. end;  
  • 相关阅读:
    关于JAVA中URL传递中文参数的问题
    java中级,知识点归纳(一)
    Python中的常见特殊方法或属性—— dir方法和dict属性
    Python中的常见特殊方法—— del方法
    Python中的常见特殊方法—— repr方法
    Python关于多继承
    Python中的@函数装饰器到底是什么?
    Python中的函数(高级使用)
    Windows怎么安装配置Elasticsearch
    Python中单元测试出错了,会怎么样?
  • 原文地址:https://www.cnblogs.com/chenjian/p/5441955.html
Copyright © 2011-2022 走看看