InnoSetup实例

; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

#define MyAppName "365Desktop"
#define MyAppVersion "1.0"
#define MyAppPublisher "ci123"
#define MyAppURL "http://www.ci123.com/"
; 可执行文件.exe
#define MyAppExeName "365Desktop.exe"
; 快捷方式.lnk
#define MyAppLnkName "365Desktop.lnk"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{82D078F3-6C3B-487A-98B9-A672C2CD2116}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
; logo
SetupIconFile=C:\Users\Administrator\Desktop\365iss\IBD.ico
; logo 右上角
WizardSmallImageFile=C:\Users\Administrator\Desktop\365iss\logo.bmp
; 左图
WizardImageFile=C:\Users\Administrator\Desktop\365iss\left.bmp 

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Tasks]
; 由用户选择是否开机自启动
Name: "startup"; Description: "随 windwos 启动"; GroupDescription: "添加启动选"

[Registry]
;添加Tasks: startup,与[Tasks]中的startup任务对应,用户选择开机自启动,对注册表的修改才会生效
Root: HKCU; SubKey: Software\Microsoft\Windows\CurrentVersion\Run; valueType: string; valueName: "{#MyAppExeName}"; valueData: "{app}\{#MyAppLnkName}";Flags: uninsdeletevalue; Tasks: startup 
;右键菜单启动项 HKEY_CLASS_ROOT\Directory\Background\shell\XXX\command 默认值为程序绝对路径
Root: HKCR; Subkey: Directory\Background\shell\365Desktop; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: Directory\Background\shell\365Desktop\command; Flags: uninsdeletekey
Root: HKCR; Subkey: Directory\Background\shell\365Desktop\command; valueType: string; valueName: ""; valueData: "{app}\Bin\Release\{#MyAppExeName}";Flags: uninsdeletevalue;

[Files]
Source: "C:\Users\Administrator\Desktop\365Desktop\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
; Flags: dontcopy [Code]代码段用文件 调用setup.dll
Source: "C:\Users\Administrator\Desktop\365Desktop\Bin\Release\setup.dll"; Flags: dontcopy
; 皮肤风格 需要引用的 ISSkin.dll 
Source: compiler:ISSkin.dll; DestDir: {app}; Flags: dontcopy 
; 皮肤风格 (*.msstyles) resources
Source: compiler:IsSkins\Office2007.cjstyles; DestDir: {tmp}; Flags: dontcopy

[Icons]
; 开始菜单中的程序启动项
Name: "{group}\{#MyAppName}"; Filename: "{app}\Bin\Release\{#MyAppExeName}"
; 安装路径,根目录下的快捷方式,可用于开机自启动项
Name: "{app}\{#MyAppName}"; Filename: "{app}\Bin\Release\{#MyAppExeName}"
; 桌面快捷方式
Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\Bin\Release\{#MyAppExeName}"
; 开始菜单中的程序卸载项
Name: "{group}\卸载365Desktop"; Filename:"{app}\卸载.exe";

[Run]
Filename: "{app}\Bin\Release\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[Code]
//修改皮肤用Load
procedure LoadSkin(lpszPath: AnsiString; lpszIniFileName: AnsiString);
external 'LoadSkin@files:isskin.dll stdcall';

//修改皮肤用Unload
procedure UnloadSkin();
external 'UnloadSkin@files:isskin.dll stdcall';

function ShowWindow(hWnd: Integer; uType: Integer): Integer;
external 'ShowWindow@user32.dll stdcall';

//安装完成时用
function  GetMacAdd():Integer;
external 'GetMacAdd@files:setup.dll stdcall setuponly delayload';

//安装结束时用
function  GetMacDel():Integer;
external 'GetMacDel@{app}\Bin\Release\setup.dll stdcall uninstallonly delayload';

//安装完成
procedure CurStepChanged(CurStep: TSetupStep);
var  
uninspath, uninsname, NewUninsName, MyAppName, strPath: string;
iErrCode: Integer;  
begin  
  if CurStep=ssDone then  
  begin  
  //指定新的卸载文件名(不包含扩展名),请相应修改!   
  NewUninsName := '卸载';  
  //应用程序名称,与 [SEUTP] 段的 AppName 必须一致,请相应修改!   
  //MyAppName := '自定义卸载文件名示例程序';  
  //以下重命名卸载文件   
  uninspath:= ExtractFilePath(ExpandConstant('{uninstallexe}'));  
  uninsname:= Copy(ExtractFileName(ExpandConstant('{uninstallexe}')),1,8);  
  RenameFile(uninspath + uninsname + '.exe', uninspath + NewUninsName + '.exe');  
  RenameFile(uninspath + uninsname + '.dat', uninspath + NewUninsName + '.dat');  
  //以下修改相应的注册表内容   
  //if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/' + MyAppName + '_is1') then  
  //begin  
  //RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/' + MyAppName + '_is1', 'UninstallString', '"' + uninspath + NewUninsName + '.exe"');  
  //RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/' + MyAppName + '_is1', 'QuietUninstallString', '"' + uninspath + NewUninsName + '.exe" /SILENT');  
  //end;

  strPath := ExpandConstant('{tmp}/setup.dll');
  if 0 <> LoadDLL(strPath, iErrCode) then 
  begin
  //统计安装量
  GetMacAdd();
  end;
  
end;  
end;  

//卸载完成
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
ErrorCode: Integer;
begin
  case CurUninstallStep of
    usUninstall:
    begin//开始卸载
    GetMacDel();
    //删除这个dll
    UnloadDLL(ExpandConstant('{app}\Bin\Release\setup.dll'));
    ///MsgBox('..\Bin\Release\error\uninstall.html',mbConfirmation, MB_OK);
    end;
    usPostUninstall:
    begin//卸载完成
    //ShellExec('open', '{app}\Bin\Release\error\uninstall.html', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
    end;
  end;
end; 

//界面初始化
procedure InitializeWizard();
begin
//WizardForm.width := 557;
//WizardForm.height := 267;
//WizardForm.WizardBitmapImage.width := WizardForm.width;
//Wizardform.WizardBitmapImage.left := 0;
end;

function InitializeSetup(): Boolean;
begin
  ExtractTemporaryFile('setup.dll');
  Result := True;

	ExtractTemporaryFile('Office2007.cjstyles');
	LoadSkin(AnsiString(ExpandConstant('{tmp}\Office2007.cjstyles')), 'NormalBlack.ini');
	Result := True;
end;

procedure DeinitializeSetup();
begin
	// Hide Window before unloading skin so user does not get
	// a glimse of an unskinned window before it is closed.
	ShowWindow(StrToInt(ExpandConstant('{wizardhwnd}')), 0);
	UnloadSkin();
end;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值