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

; Script generated by the Inno Setup 脚本向导.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

; 为1的时候表示定义成试用版本
#define VERSION_TYPE ReadIni('Setup.ini', 'SetupType', 'type', '0')

#if VERSION_TYPE == "2"
	#define LIVE_VERSION
	#define MyAppName "流媒体系统(PMS)"
	#define MyAppId "1954A698-2322-46F1-B732-8DDF96693DA5"
	#define MyOutputBaseFilename "live_server_setup"
#elif VERSION_TYPE == "1"
	#define VOD_VERSION
	#define MyAppName "流媒体系统(PMS)"
	#define MyAppId "DA255679-F103-4170-8B75-B9A7EF4CBC1B"
	#define MyOutputBaseFilename "vod_server_setup"
#else
	#define FULL_VERSION
	#define MyAppName "流媒体系统(PMS)"
	#define MyAppId "4AC618B5-8C69-4D47-918A-261AA895B6D7"
	#define MyOutputBaseFilename "full_server_setup"
#endif

#define RegUrl "http://www.xxx.net"
#define MyAppVersion "1.0"
#define MyAppPublisher "XXX科技有限公司"
#define MyAppURL "http://www.xxx.net"
#define MyAppExeName "InstanceConfig.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{{#MyAppId}}
AppMutex={{{#MyAppId}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\xxx\media server
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=license.txt
OutputDir=output
OutputBaseFilename={#MyOutputBaseFilename}
SetupIconFile=setup.ico
Compression=lzma
SolidCompression=yes

VersionInfoVersion={#MyAppVersion}
VersionInfoCompany={#MyAppPublisher}
VersionInfoCopyright=Copyright (C) 2010-2013
VersionInfoProductName={#MyAppName}
VersionInfoProductVersion={#MyAppVersion}

[Languages]
Name: cn; MessagesFile: compiler:Languages\chinese.isl

[Files]
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
; 用来检测安装程序中输入的注册码是否有效
Source: ..\build\register_help.dll; Flags: dontcopy
Source: ..\build\libeay32.dll; Flags: dontcopy
Source: ..\build\vcredist2008_x86.exe; Flags: dontcopy

#ifdef FULL_VERSION
Source: ..\build\server.conf; DestDir: {app}
Source: ..\build\media_service.exe; DestDir: {app}
Source: ..\build\libmysql.dll; DestDir: {app}
Source: ..\build\libeay32.dll; DestDir: {app}
Source: ..\build\zlib1.dll; DestDir: {app}
Source: ..\build\register_check.exe; DestDir: {app}
Source: ..\build\QtCore4.dll; DestDir: {app}
Source: ..\build\QtGui4.dll; DestDir: {app}
Source: ..\build\mglobal.dll; DestDir: {app}
Source: ..\build\msvcp100.dll; DestDir: {app}
Source: ..\build\msvcr100.dll; DestDir: {app}
Source: ..\build\initconfig.exe; DestDir: {app}
Source: ..\build\InstanceConfig.exe; DestDir: {app}
;Source: ..\build\php-fpm.exe; DestDir: {app}
Source: ..\build\管理统计页面.url; DestDir: {app}
Source: ..\build\示例页面.url; DestDir: {app}

Source: ..\build\launchlist; DestDir: {app}
;Source: ..\build\phpcgi; DestDir: {app}

Source: ..\build\lighttpd.conf; DestDir: {app}\lmp\lighttpd\conf; Flags: ignoreversion
Source: ..\build\my.ini; DestDir: {app}\lmp\mysql; Flags: ignoreversion

; web服务器整套目录
Source: ..\build\lmp\*; DestDir: {app}\lmp; Flags: recursesubdirs createallsubdirs
; doc文档目录
Source: ..\doc\*; DestDir: {app}\help; Flags: recursesubdirs createallsubdirs
; 播放器相关目录
Source: ..\build\swfs\*; DestDir: {app}\swfs; Flags: recursesubdirs createallsubdirs
; 播放器SDK相关目录
Source: ..\build\scriptlib\*; DestDir: {app}\scriptlib; Flags: recursesubdirs createallsubdirs

#endif

[Dirs]
Name: {app}\videos

[Tasks]
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}

[Icons]
Name: {group}\sample\示例页面; Filename: {app}\示例页面.url

Name: {group}\help\安装说明; Filename: {app}\help\安装说明.pdf
Name: {group}\help\功能说明; Filename: {app}\help\功能说明.pdf
Name: {group}\help\开发说明; Filename: {app}\help\开发说明.pdf
Name: {group}\help\配置说明; Filename: {app}\help\配置说明.pdf
Name: {group}\help\统计模块; Filename: {app}\help\统计模块.pdf

Name: {group}\流媒体系统(PMS)系统配置; Filename: {app}\{#MyAppExeName}
Name: {group}\{cm:UninstallProgram, PMS系统配置}; Filename: {uninstallexe}
Name: {group}\流媒体系统(PMS)统计管理; Filename: {app}\管理统计页面.url; IconFilename: {app}\{#MyAppExeName};
Name: {commondesktop}\流媒体系统(PMS)统计管理; Filename: {app}\管理统计页面.url; Tasks: desktopicon; IconFilename: {app}\{#MyAppExeName};
Name: {commondesktop}\流媒体系统(PMS)系统配置; Filename: {app}\{#MyAppExeName}; Tasks: desktopicon
Name: {commondesktop}\开启PMS服务; Filename: {app}\media_service.exe; Parameters: -r; IconFilename: {app}\{#MyAppExeName}; Tasks: desktopicon
Name: {commondesktop}\停止PMS服务; Filename: {app}\media_service.exe; Parameters: -s; IconFilename: {app}\{#MyAppExeName}; Tasks: desktopicon

[Run]
; 删除服务
Filename: {app}\media_service.exe; Parameters: -u; Flags: runhidden
; 安装服务
Filename: {app}\media_service.exe; Parameters: -i; Flags: runhidden

[UninstallRun]
; 停止服务
Filename: {app}\media_service.exe; Parameters: -s; Flags: runhidden
; 删除服务
Filename: {app}\media_service.exe; Parameters: -u; Flags: runhidden

[CustomMessages]
Key_Form_Caption=注册向导
Key_Form_Description=将序列号提交给xxx以获取注册码
Key_Form_codeLabel_Caption0=序列号:
Key_Form_keyLabel_Caption0=注册码:

Domain_Form_Caption=域名设置
Domain_Form_Description=配置当前服务器域名

[Messages]
BeveledLabel=xxx网络科技

[Code]
var
	codeLabel: TLabel;
	keyLabel: TLabel;
	key: TMemo;
	code: TMemo;
  keyPage: TWizardPage;
  domainEdit: TNewEdit;
  domainPage: TWizardPage;

// 获取序列号
function getCode(szCode: PChar; inLen: Integer): Integer;
external 'getCode@files:register_help.dll,libeay32.dll,msvcr100.dll stdcall setuponly delayload loadwithalteredsearchpath';

// 进行检查
function regCheck(const regKey: PChar): Boolean;
external 'regCheck@files:register_help.dll,libeay32.dll,msvcr100.dll stdcall setuponly delayload loadwithalteredsearchpath';

// 进行注册
function regSave(const regKey, regPath: PChar): Boolean;
external 'regSave@files:register_help.dll,libeay32.dll,msvcr100.dll stdcall setuponly delayload loadwithalteredsearchpath';

// 清理注册
procedure regClear(const regPath: PChar);
external 'regClear@files:register_help.dll,libeay32.dll,msvcr100.dll stdcall setuponly delayload loadwithalteredsearchpath';

function OpenSCManager(const machine: LongInt; const dbName: LongInt;  access: Dword):LongInt;
external 'OpenSCManagerA@Advapi32.dll stdcall';

function OpenService(svcMgr: LongInt; const svcName: pchar;  access: Dword):LongInt;
external 'OpenServiceA@Advapi32.dll stdcall';

function CloseServiceHandle(svc: LongInt):Boolean;
external 'CloseServiceHandle@Advapi32.dll stdcall';

///判定服务是否存在
function  serviceExists(name: string): boolean;
var
    SvcMgr, Svc: LongInt;
begin
    Result := False;
    SvcMgr := OpenSCManager(0,0,1);
    if SvcMgr = 0 then Exit;
    Svc := OpenService(SvcMgr, PChar(name), 4);
    if Svc = 0 then
    begin
      CloseServiceHandle(SvcMgr);
      Exit;
    end;
    CloseServiceHandle(Svc);
    CloseServiceHandle(SvcMgr);
    Result := true;
end;

///停止服务
procedure stopService;
var
  ResultCode: Integer;
begin
  Exec(ExpandConstant('{tmp}\media_service.exe'), '-s', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;

{ Key_Form_ShouldSkipPage }

function Key_Form_ShouldSkipPage(Page: TWizardPage): Boolean;
var
	codeStr: String;
begin
	SetLength(codeStr, 1024);
	getCode(PChar(codeStr), 1024);
	code.Text := codeStr;
	Result := False;
end;

// 注册码编辑框改变事件
procedure Key_Form_KeyChange(Sender: TObject);
begin
// 检测注册码
	if regCheck(PChar(key.Text)) then
		WizardForm.NextButton.Enabled := True
	else
		WizardForm.NextButton.Enabled := False;
end;

procedure RegURLLabelOnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  ShellExec('open', ExpandConstant('{#RegURL}'), '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

{ Key_Form_CreatePage }
function Key_Form_CreatePage(PreviousPageId: Integer): Integer;
var
  URLLabel: TNewStaticText;
begin
	keyPage := CreateCustomPage(
              PreviousPageId,
              ExpandConstant('{cm:Key_Form_Caption}'),
              ExpandConstant('{cm:Key_Form_Description}')
          );

  { codeLabel }
	codeLabel := TLabel.Create(keyPage);
	with codeLabel do
	begin
		Parent := keyPage.Surface;
		Caption := ExpandConstant('{cm:Key_Form_codeLabel_Caption0}');
		Left := ScaleX(0);
		Top := ScaleY(0);
		Width := ScaleX(40);
		Height := ScaleY(13);
	end;

  { keyLabel }
	keyLabel := TLabel.Create(keyPage);
	with keyLabel do
	begin
		Parent := keyPage.Surface;
		Caption := ExpandConstant('{cm:Key_Form_keyLabel_Caption0}');
		Left := ScaleX(0);
		Top := ScaleY(82);
		Width := ScaleX(40);
		Height := ScaleY(13);
	end;

  { key }
	key := TMemo.Create(keyPage);
	with key do
	begin
		Parent := keyPage.Surface;
		Left := ScaleX(0);
		Top := ScaleY(98);
		Width := ScaleX(410);
		Height := ScaleY(106);
		ScrollBars := ssVertical;
		TabOrder := 0;
    OnChange := @Key_Form_KeyChange;
	end;

  { code }
	code := TMemo.Create(keyPage);
	with code do
	begin
		Parent := keyPage.Surface;
		Left := ScaleX(0);
		Top := ScaleY(16);
		Width := ScaleX(410);
		Height := ScaleY(60);
		ReadOnly := True;
		ScrollBars := ssVertical;
		TabOrder := 1;
	end;

	with keyPage do
	begin
		OnShouldSkipPage := @Key_Form_ShouldSkipPage;
	end;

	Result := keyPage.ID;

  URLLabel := TNewStaticText.Create(keyPage);
  with URLLabel do
  begin
    Caption := '获取注册码';
    Cursor := crHand;
    OnClick := @RegURLLabelOnClick;
    Parent := keyPage.Surface;
    Font.Style := URLLabel.Font.Style + [fsUnderline];
    Font.Color := clBlue;
    Left := ScaleX(350);
    Top := ScaleY(210);
  end;
end;

{ 设置域名页面相关代码 }
procedure Domain_Form_EditChange(sender: TObject);
begin
  if domainEdit.Text = '' then
    WizardForm.NextButton.Enabled := False
  else
    WizardForm.NextButton.Enabled := True;
end;

function Domain_Form_CreatePage(PreviousPageId: Integer): Integer;
var
  domainLabel: TNewStaticText;
begin
	domainPage := CreateCustomPage(
              PreviousPageId,
              ExpandConstant('{cm:Domain_Form_Caption}'),
              ExpandConstant('{cm:Domain_Form_Description}')
          );

  domainLabel := TNewStaticText.Create(domainPage);
  with domainLabel do
  begin
    Parent := domainPage.Surface;
    Caption := '请确保输入的域名是有效的,并指向当前服务器IP,否则可以直接填写本机' + #13#10 + 'IP地址,或者保持默认值不变';
		Left := ScaleX(0);
		Top := ScaleY(60);
		Width := ScaleX(400);
		Height := ScaleY(28);
  end;
  
  domainEdit := TNewEdit.Create(domainPage);
  with domainEdit do
  begin
    Parent := domainPage.Surface;
    Text := GetComputerNameString;
		Left := ScaleX(0);
		Top := ScaleY(90);
		Width := ScaleX(400);
		Height := ScaleY(13);
    OnChange := @Domain_Form_EditChange;
  end; 
end;

procedure URLLabelOnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  ShellExec('open', ExpandConstant('{#MyAppURL}'), '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

// 安装初始化
function InitializeSetup(): Boolean;
begin
  if serviceExists('MediaSrv') then
  begin //服务存在,先停止它
    if MsgBox('服务已经存在,要继续吗?', mbConfirmation, MB_YESNO) = IDNO then
    begin
      Result := False;
      Exit;
    end;
    ExtractTemporaryFile('media_service.exe');
    ExtractTemporaryFile('msvcr100.dll');
    ExtractTemporaryFile('msvcp100.dll');
    stopService;
  end;
	result := True;
end;

procedure InitializeWizard();
var
  URLLabel: TNewStaticText;
begin
	Key_Form_CreatePage(wpSelectDir);
  Domain_Form_CreatePage(keyPage.ID);

  URLLabel := TNewStaticText.Create(WizardForm);
  with URLLabel do
  begin
    Caption := ExpandConstant('{#MyAppURL}');
    Cursor := crHand;
    OnClick := @URLLabelOnClick;
    Parent := WizardForm;
    Font.Style := URLLabel.Font.Style + [fsUnderline];
    Font.Color := clBlue;
    Left := ScaleX(20);
    Top := WizardForm.ClientHeight - ScaleY(30);
  end;
end;

// 页面切换事件
procedure CurPageChanged(CurPageID: Integer);
var
  ResultCode: Integer;
  file: String;
  buf: String;
begin
  WizardForm.BackButton.Enabled := True;

  if CurPageID = keyPage.ID then
    WizardForm.NextButton.Enabled := False
  else if CurPageID = wpFinished then
  begin
    ///
    // 帮助设置HOST_NAME为用户设置的域名
    file := ExpandConstant('{app}\lmp\htdocs\sample\config.php');
    if LoadStringFromFile(file, buf) then
    begin
      StringChangeEx(buf, '%HOST_NAME%', domainEdit.Text, False);
      SaveStringToFile(file, buf, False);
    end;

    file := ExpandConstant('{app}\管理统计页面.url');
    if LoadStringFromFile(file, buf) then
    begin
      StringChangeEx(buf, '%HOST_NAME%', domainEdit.Text, False);
      SaveStringToFile(file, buf, False);
    end;

    file := ExpandConstant('{app}\示例页面.url');
    if LoadStringFromFile(file, buf) then
    begin
      StringChangeEx(buf, '%HOST_NAME%', domainEdit.Text, False);
      SaveStringToFile(file, buf, False);
    end;
    ///

    // 禁用完成按钮
    WizardForm.NextButton.Enabled := False;
    // 正式写入注册文件
    regSave(PChar(key.Text), WizardDirValue);
    // 执行自动初始化
    Exec(ExpandConstant('{app}\initconfig.exe'), '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
    // 执行配置设置
    Exec(ExpandConstant('{app}\InstanceConfig.exe'), '-r', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
    // 启动服务
    Exec(ExpandConstant('{app}\media_service.exe'), '-r', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
    // 启用完成按钮
    WizardForm.NextButton.Enabled := True;
  end
  else if CurPageID = wpInstalling then
  begin
    // 安装运行时库
    ExtractTemporaryFile('vcredist2008_x86.exe');
    // 执行2008库安装
    Exec(ExpandConstant('{tmp}\vcredist2008_x86.exe'), '/q', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  end
  else if CurPageID = domainPage.ID then
  begin
    WizardForm.BackButton.Enabled := False;
  end;
end;

// 卸载
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  if CurUninstallStep = usUninstall then
  begin
    DeleteFile(ExpandConstant('{app}\lsc'));
  end;
end;

// 检查重启逻辑
function UninstallNeedRestart(): Boolean;
begin
  if serviceExists('MediaSrv') then
    result := True
  else
    result := False;
end;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: InnoSetup是一个易于使用的安装包制作工具,它提供了丰富的安装选项和自定义功能。在使用InnoSetup制作安装包时,我们可以通过自定义安装界面来满足客户的各种需求。 通过InnoSetup的宏命令和脚本语言,我们可以轻松地修改默认的安装界面,例如添加自定义控件、更改按钮文本、更改字体和颜色等。可以使用Pascal脚本和Delphi Object Pascal语言。 要自定义安装界面,我们需要首先打开InnoSetup脚本文件(.iss文件)并找到“[Setup]”部分。在这里,我们可以设置安装程序的各种选项,例如安装的目标路径、是否需要安装桌面快捷方式、是否需要安装开始菜单项等等。 然后,我们可以添加新的页面和自定义控件,例如选择安装选项的页面、选择安装路径的页面、选择应用程序图标的页面等等。我们可以使用InnoSetup自带的控件,也可以使用自定义控件来实现更复杂的功能。 最后,我们可以为每个页面添加Pascal脚本来实现自定义逻辑,例如检查安装目录是否已存在、检查系统是否已安装必要的组件等等。 总之,InnoSetup提供了灵活的自定义安装界面功能,让我们可以满足不同客户的需求,并提高软件的用户体验。 ### 回答2: Inno Setup 可以在安装过程中自定义安装界面,使其更符合特定的软件需求和个性化需求。通过自定义安装界面,可以加强用户交互体验,提高软件的可用性和易用性,同时也可以为软件提供更精细的管理和控制。下面将分别从设计理念、开发流程和技术实现方面进行介绍。 设计理念 Inno Setup自定义安装界面开发过程,从本质上来说是一次用户交互设计 (User Experience Design, UXD) 的过程。通过 UXD,设计师可以了解客户的需求、喜好和习惯,进而设计出更符合其需求的产品和服务。在自定义安装界面开发流程中,设计师需要考虑以下几个方面: 1. 界面设计。界面设计应该简单明了、美观大方,能够吸引用户的注意力并提高用户的参与度。同时需要考虑不同用户的操作习惯和口味,以达到更广泛的用户群体。 2. 用户体验 (User Experience, UX) 设计。在设计界面时,需要考虑到用户的体验。例如:简化繁琐的操作、提供更多的选择、给予良好的反馈等都是好的用户体验设计。 3. 交互设计。特别是在软件界面方面,设计师需要思考用户将与之如何交互,如何设定第一时间与其进行沟通交流。 开发流程 在设计理念上确定了之后,我们需要有一个中间人对需求进行保存和整理。通常情况下需要特别有经验的的开发人员还需要具备美工能力,能够从业务流程到界面交互再到发布之间都能够进行系统性的构建和实践。 首先,需要准备安装向导的图片资源、控件资源等基本素材,并制定对应的管理策略。然后在1.4版本以上的 Inno Setup 中,我们可以手动复制 Setup 向导的默认源文件,再进行相应的更改即可。 接着,需要使用 Pascal 编写脚本来确保安装向导能够正确检测到用户的操作,以及完成相应的安装任务。同时,还需要定义安装向导的菜单项、默认值、文件读取方式等,以方便用户进行自定义设置和个性化操作。 最后,在整个自定义安装界面开发完成后,我们需要使用 Inno Setup 自带的编译器工具将代码打包并生成可供安装安装包,从而方便用户进行安装和使用。 技术实现方案 实现自定义安装界面的技术方案主要分为以下几个方面: 1. 界面设计工具。可以选择比较流行的界面设计工具,如 Adobe Photoshop,Axure RP,Sketch 等,这些工具都具有快速地设计复杂界面的能力。 2. 编程语言。Inno Setup 采用 Pascal 语言编写,因此需要对 Pascal 语言有一定的了解和掌握基本的编程技能。 3. Inno Setup 插件。InnoSetup 提供了一系列插件,可以方便我们在安装向导中引入大量有用的功能,如申请服务权限、加密等。 需要注意的是,Inno Setup 自定义安装界面开发风格应该以简单、实用、易于维护为原则,在设计时需要注意不要过于复杂和繁琐,以方便用户进行快速的操作和安装。 ### 回答3: Inno Setup是一款功能强大的安装程序制作软件,它可以帮助开发者快速的制作出安装程序。而自定义安装界面则是Inno Setup所提供的一个很实用的功能之一,它可以使得开发者可以自由的设计自己的安装界面,让用户有一个更加舒适的安装体验。 首先,我们需要了解Inno Setup自定义安装界面的实现方式。整个安装过程中,Inno Setup会按照一定的流程逐步展示各个界面,在每一个界面上,开发者都可以通过界面的设计和编写代码来进行自定义。 在设计安装界面时,我们可以使用Inno Setup自带的画布工具或者其他画图工具来设计出自己喜欢的安装界面,然后通过Inno Setup的代码来添加各种控件和事件。例如,我们可以添加各种按钮、文本框、进度条、复选框等控件,并通过代码来控制它们的显示和行为。 接下来,我们需要考虑自定义安装界面需要实现哪些功能。例如,我们可能需要在安装界面中添加自己的公司Logo、版本号、安装路径等信息,或者添加一些用户需要填写的信息,比如用户的名称、电子邮件和密码等。如果需要,我们也可以添加自己的安装协议和许可协议,并让用户需要点击同意才能继续安装。 总的来说,Inno Setup自定义安装界面功能非常强大,可以让开发者灵活的设计和实现自己的安装界面。但是需要注意的是,设计一个良好的安装界面需要考虑到用户的体验和操作方式,所以我们需要仔细考虑每一个控件的设计和布局,让用户能够尽可能的了解整个安装过程,并且保持简洁和易于操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值