我在INNO SETUP中复制了InitializeSetup,我该如何解决? [英] I have duplicated InitializeSetup in INNO SETUP how can i solve it?

查看:249
本文介绍了我在INNO SETUP中复制了InitializeSetup,我该如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试使用INNO SETUP创建安装程序,当我开始使用ISSkin代码时,Inno安装程序向我发送了错误消息DUPLICATE IDENTIFIER'INITIALIZESETUP',我想知道我必须更改我的代码才能使其工作.

Hello i am trying to make an installer using INNO SETUP, when i started to use ISSkin Code Inno setup send me an error mesage DUPLICATE IDENTIFIER 'INITIALIZESETUP' I would like to know what i have to change to my code to make it work.

我在互联网上阅读,发现了一个名为IS Script Joiner的程序,我使用了它,但是它不起作用.

I was reading at internet and i found a program called IS Script Joiner, i used it but it doesnt work.

这是我的Inno代码:

Here is my Inno Code:

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

#define MyAppName "Myprogram"
#define MyAppVersion "2.8"
#define MyAppPublisher "Myprogram"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "program.exe"
#define ISSI_WizardSmallBitmapImage "wpBanner.bmp"
#define ISSI_WizardSmallBitmapImage_x 495
#define ISSI_WizardSmallBitmapImage_Align
#define ISSI_IncludePath "C:\ISSI"
#include ISSI_IncludePath+"\_issi.isi"

[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={{2A8CE1DB-2FDB-4CAA-8A2C-0FE3DB8A500D}
AppName=Myprogram
AppVersion=2.8
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher=Myprogram
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\Myprogram
DefaultGroupName={#MyAppName}
LicenseFile=C:\Libraries\EULA.rtf
OutputDir=C:\Users\Hans Lopez\INNO SETUPS
OutputBaseFilename=programoutput
SetupIconFile=C:\Libraries\Icon.ico
Compression=lzma/Max
SolidCompression=true
WizardImageFile=C:\InstallMlockPackage\Setupbanner.bmp
AppVerName=2.8
DirExistsWarning=yes
VersionInfoProductName=Myprogram
VersionInfoProductVersion=2.8



[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"

[Dirs]
Name: "{app}" ; Permissions: everyone-full
Name: {sd}\myprogramfolder; Permissions: everyone-full; 


[Code]
//===================================================================Verify if                     Installed===============================================================================
function GetUninstallString: string;
var
sUnInstPath: string;
sUnInstallString: String;
begin
Result := '';

   sUnInstallString := '';
   if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
    RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
   Result := sUnInstallString;
   end;

   function IsUpgrade: Boolean;
begin
Result := (GetUninstallString() <> '');
end;

function InitializeSetup: Boolean;
var
  V: Integer;
  iResultCode: Integer;
  sUnInstallString: string;
begin
  Result := True; // in case when no previous version is found
  if                    RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\ {2A8CE1DB-2FDB-4CAA-8A2C-0FE2DB8A500D}_is1', 'UninstallString') then  //Your App GUID/ID
  begin
    V := MsgBox(ExpandConstant('Myprogram is Already installed, Do you want to         continue?'), mbInformation, MB_YESNO); //Custom Message if App installed
    if V = IDYES then
    begin
      sUnInstallString := GetUninstallString();
      sUnInstallString :=  RemoveQuotes(sUnInstallString);
      Exec(ExpandConstant(sUnInstallString), '', '', SW_SHOW, ewWaitUntilTerminated,     iResultCode);
      Result := True; //if you want to proceed after uninstall
                //Exit; //if you want to quit after uninstall
    end
    else
      Result := False; //when older version present and not uninstalled
  end;
end;

//====================================================================Unistall and Delete Everything==================================================================

procedure DeleteBitmaps(ADirName: string);
var
  FindRec: TFindRec;
begin
  if FindFirst(ADirName + '\*.*', FindRec) then begin
    try
      repeat
        if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then begin
          if (FindRec.Name <> '.') and (FindRec.Name <> '..') then begin
            DeleteBitmaps(ADirName + '\' + FindRec.Name);
            RemoveDir(ADirName + '\' + FindRec.Name);
          end;
        end else if Pos('.bmp', AnsiLowerCase(FindRec.Name)) > 0 then
          DeleteFile(ADirName + '\' + FindRec.Name);
      until not FindNext(FindRec);
    finally
      FindClose(FindRec);
    end;
  end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  if CurUninstallStep = usUninstall then begin
    if MsgBox('Do you want to delete all data files?', mbConfirmation,
        MB_YESNO) = IDYES 
    then begin
      DeleteBitmaps(ExpandConstant('{app}'));
    end;
  end;
end;


//===========================================================ISSKinCODE=============================================================================



// Importing LoadSkin API from ISSkin.DLL
procedure LoadSkin(lpszPath: String; lpszIniFileName: String);
external 'LoadSkin@files:isskin.dll stdcall';

// Importing UnloadSkin API from ISSkin.DLL
procedure UnloadSkin();
external 'UnloadSkin@files:isskin.dll stdcall';

// Importing ShowWindow Windows API from User32.DLL
function ShowWindow(hWnd: Integer; uType: Integer): Integer;
external 'ShowWindow@user32.dll stdcall';


function InitializeSetup(): Boolean;
begin
  ExtractTemporaryFile('iTunesB.msstyles');
  LoadSkin(ExpandConstant('{tmp}\iTunesB.msstyles'), '');
  Result := True;
end;

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



/////////////////////////////////////////////////////////////ENDCODE/////////////////////////////////////////////////////////////////////////////////////////////////




[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "                  {cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "    {cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
Source: "C:\My program\program.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Program Files\C:\My program\*"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\programfolder\*"; DestDir: "{sd}\Myprogramfolder"; Flags: ignoreversion             recursesubdirs createallsubdirs
Source: ISSkin.dll; DestDir: {app}; Flags: dontcopy
Source: "C:\InstallMlockPackage\ISSkin\iTunesB\iTunesB\iTunesB.msstyles"; DestDir: "    {tmp}"; Flags: dontcopy



; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}";  IconFilename: "    {app}\icon.ico" ;
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}";  IconFilename: "{app}\icon.ico" ;
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}";      IconFilename: "{app}\icon.ico" ;
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks:     desktopicon;  IconFilename: "{app}\icon.ico" ;
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon;  IconFilename: "{app}\icon.ico" ;
Name: {group}\Uninstall =ISSkin; Filename: {app}\unins000.exe
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,         {#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

非常感谢您的帮助

推荐答案

将对ISSkin DLL的两个调用从它们现在所在的位置(第二个InitializeSetup之上)重新定位到第一个InitializeSetup声明的正上方. >

Relocate the two calls to the ISSkin DLL from where they are now (above the second InitializeSetup) to just above the first InitializeSetup declaration.

// Importing LoadSkin API from ISSkin.DLL
procedure LoadSkin(lpszPath: String; lpszIniFileName: String);
external 'LoadSkin@files:isskin.dll stdcall';

// Importing UnloadSkin API from ISSkin.DLL
procedure UnloadSkin();
external 'UnloadSkin@files:isskin.dll stdcall';

更改第一个InitializeSetup代码以包括提取和加载皮肤的调用(来自第二个InitializeSetup).

Change the first InitializeSetup code to include the calls to extract and load the skin (from the second InitializeSetup).

function InitializeSetup: Boolean;
var
  V: Integer;
  iResultCode: Integer;
  sUnInstallString: string;
begin
  // These two lines moved from second InitializeSetup declaration before it
  // was removed.
  ExtractTemporaryFile('iTunesB.msstyles');
  LoadSkin(ExpandConstant('{tmp}\iTunesB.msstyles'), '');
  Result := True; // in case when no previous version is found
  if                    RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\ {2A8CE1DB-2FDB-4CAA-8A2C-0FE2DB8A500D}_is1', 'UninstallString') then  //Your App GUID/ID
  begin
    V := MsgBox(ExpandConstant('Myprogram is Already installed, Do you want to         continue?'), mbInformation, MB_YESNO); //Custom Message if App installed
    if V = IDYES then
    begin
      sUnInstallString := GetUninstallString();
      sUnInstallString :=  RemoveQuotes(sUnInstallString);
      Exec(ExpandConstant(sUnInstallString), '', '', SW_SHOW, ewWaitUntilTerminated,     iResultCode);
      Result := True; //if you want to proceed after uninstall
                //Exit; //if you want to quit after uninstall
    end
    else
      Result := False; //when older version present and not uninstalled
  end;
end;

完全删除第二个InitializeSetup代码.

这篇关于我在INNO SETUP中复制了InitializeSetup,我该如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆