Inno-setup Example

  1 ; Script generated by the Inno Setup Script Wizard.
  2 ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
  3 
  4 #define MyAppName "sndaloginguard"
  5 #define MyAppPublisher "SNDA, Inc."
  6 #define MyAppURL "http://www.sdo.com/"
  7 
  8 ;
  9 #define MyAppVersion "1.0.0"
 10 #define MyDefaultInstallDir "C:\Program Files\盛大网络\登录助手\"
 11 #define MyDefaultPackDir    ".\temp\"
 12 
 13 [Setup]
 14 ; NOTE: The value of AppId uniquely identifies this application.
 15 ; Do not use the same AppId value in installers for other applications.
 16 ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
 17 ;PrivilegesRequired=admin
 18 AppId={{3D662258-0CAF-4F56-988C-7F12F0DB7ECF}
 19 AppName={#MyAppName}
 20 AppVersion={#MyAppVersion}
 21 ;AppVerName={#MyAppName} {#MyAppVersion}
 22 AppPublisher={#MyAppPublisher}
 23 AppPublisherURL={#MyAppURL}
 24 AppSupportURL={#MyAppURL}
 25 AppUpdatesURL={#MyAppURL}
 26 DefaultDirName={#MyDefaultInstallDir}
 27 DefaultGroupName={#MyAppName}
 28 OutputBaseFilename=sndaloginguard_{#MyAppVersion}
 29 SetupIconFile=..\..\sdostate-debug\logo.ico
 30 Compression=lzma
 31 SolidCompression=yes
 32 
 33 [Languages]
 34 Name: "english"; MessagesFile: "compiler:Default.isl"
 35 
 36 [Files]
 37 Source: {#MyDefaultPackDir}\duilib.dll; DestDir: "{app}"; Flags: ignoreversion
 38 Source: {#MyDefaultPackDir}\GdiPlus.dll; DestDir: "{app}"; Flags: ignoreversion
 39 Source: {#MyDefaultPackDir}\skin.zip; DestDir: "{app}"; Flags: ignoreversion
 40 Source: {#MyDefaultPackDir}\sndaloginguard.exe; DestDir: "{app}"; Flags: ignoreversion
 41 Source: {#MyDefaultPackDir}\adcore.dll; DestDir: "{app}"; Flags: ignoreversion
 42 Source: {#MyDefaultPackDir}\StatisticInstallInfo.dll; DestDir: "{app}"; Flags: ignoreversion
 43 Source: {#MyDefaultPackDir}\updatedownload.exe; DestDir: "{app}"; Flags: ignoreversion
 44 Source: {#MyDefaultPackDir}\update.dll; DestDir: "{app}"; Flags: ignoreversion
 45 Source: {#MyDefaultPackDir}\config\*.*; DestDir: "{app}\config"; Flags: ignoreversion
 46 ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
 47 
 48 [Icons]
 49 Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppName}"
 50 Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
 51 
 52 [Registry]
 53 Root:HKLM;Subkey:SOFTWARE\snda\sndaloginguard; ValueType: string; ValueName:Path;ValueData:{app}\sndaloginguard.exe;Flags: uninsdeletevalue
 54 
 55 
 56 [Run]
 57 ;Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
 58 Filename: "{app}\sndaloginguard.exe ";  Parameters:"-INSTALL";  Flags: nowait 
 59 [Code]
 60 
 61 procedure Installed(nActionID:Integer);
 62 external 'Installed@files:StatisticInstallInfo.dll cdecl  setuponly';
 63 
 64 procedure Uninstalled(nActionID:Integer);
 65 external 'Uninstalled@{app}\StatisticInstallInfo.dll cdecl uninstallonly';
 66 
 67 function IsStatesvrExist():Integer;
 68 external 'IsStatesvrExist@{app}\StatisticInstallInfo.dll stdcall uninstallonly';
 69 
 70 function GetMyParam(PName:string):string;
 71 var
 72   CmdLine : String;                        
 73   CmdLineLen : Integer;
 74   i : Integer;
 75 begin
 76     Result := '';
 77     CmdLineLen:=ParamCount();
 78     for i:=0 to CmdLineLen do
 79     begin
 80     CmdLine:=ParamStr(i);
 81     if CmdLine = PName then
 82       begin
 83           CmdLine:=ParamStr(i+1);
 84           Result := CmdLine;
 85           Exit;
 86       end;
 87     end;
 88 end;
 89                                      
 90 procedure DeinitializeSetup();
 91 var 
 92 res: String;
 93 nActionID:Integer;
 94 
 95 begin
 96 res := GetMyParam('-myParam');
 97 nActionID := 1001;
 98 Installed(nActionID);
 99 end;
100 
101 procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
102 var
103 nActionID:Integer;
104 begin
105   // Call our function just before the actual uninstall process begins
106   nActionID := 1002;
107   if CurUninstallStep = usUninstall then
108   begin
109     Uninstalled(nActionID);
110     // Now that we're finished with it, unload MyDll.dll from memory.
111     // We have to do this so that the uninstaller will be able to remove the DLL and the {app} directory.
112     UnloadDLL(ExpandConstant('{app}\StatisticInstallInfo.dll'));
113     //delete everything under {app}\
114     DelTree(ExpandConstant('{app}'), True, True, True);
115   end;
116 end;
117 
118 function InitializeUninstall(): Boolean;
119 var 
120 HasRun : Integer;
121 begin
122   HasRun := IsStatesvrExist();
123   if HasRun = 1 then
124   begin
125     MsgBox('卸载程序检测到你的应用程序正在运行。' #13#13 '请先退出你的应用程序,然后再进行卸载!', mbError, MB_OK);
126     Result := false;
127   end
128   else
129     Result := true;
130 end;
posted @ 2012-09-25 11:25  可乐爱上了雪碧  阅读(1078)  评论(0编辑  收藏  举报