2016-07-16 75 views
-2

我想通過修改源代碼Inno Setup Compiler 5.5.9 Unicode來使我的Inno Setup Script創建uninstaller.exe文件進行卸載,而不是unins000.exe在Inno Setup中通過編輯Install.pas Delphi單元重命名「unins000.exe」

我打開Delphi單元Install.pas具有這些代碼:

procedure GenerateUninstallInfoFilename; 
    var 
    ExistingFiles: array[0..999] of Boolean; 
    BaseDir: String; 

    procedure FindFiles; 
    var 
     H: THandle; 
     FindData: TWin32FindData; 
     S: String; 
    begin 
     H := FindFirstFile(PChar(AddBackslash(BaseDir) + 'unins???.*'), 
    FindData); 
     if H <> INVALID_HANDLE_VALUE then begin 
     repeat 
      S := FindData.cFilename; 
      if (Length(S) >= 9) and (CompareText(Copy(S, 1, 5), 'unins') = 0) and 
     CharInSet(S[6], ['0'..'9']) and CharInSet(S[7], ['0'..'9']) and CharInSet(S[8], ['0'..'9']) and 
     (S[9] = '.') then 
      ExistingFiles[StrToInt(Copy(S, 6, 3))] := True; 
     until not FindNextFile(H, FindData); 
     Windows.FindClose(H); 
    end; 
end; 

procedure GenerateFilenames(const I: Integer); 
var 
    BaseFilename: String; 
begin 
    BaseFilename := AddBackslash(BaseDir) + Format('unins%.3d', [I]); 
    UninstallExeFilename := BaseFilename + '.exe'; 
    UninstallDataFilename := BaseFilename + '.dat'; 
    UninstallMsgFilename := BaseFilename + '.msg'; 
end; 

我想改變這個代碼來創建uninstaller.exe , uninstaller.dat , uninstaller.msg文件時,設置保存卸載信息。

因此,如果安裝程序檢測到舊uninstaller.exe試圖重新安裝程序而無需卸載任何其舊的安裝時,安裝程​​序應檢測到舊uninstaller.exe和覆蓋它無需任何用戶確認。

使用的編譯器:CodeGear RAD Studio with Delphi 2009 Update 4

我想知道我該怎麼做,我只會做這個測試的目的。

重命名後的unins000.exeuninstaller.exe,貌似創新安裝找不到卸載日誌文件或任何其他錯誤.........

Setup Crashes on second re-installation over an old installation

謝謝你的幫助。

+0

可能還有更多相關的代碼。你有沒有考慮聘請程序員,或者學習編程自己。程序員將能夠理解代碼並知道如何改變它。很明顯,您希望通過刪除編號邏輯來進行重大更改。 –

+0

但@DavidHeffernan請...........我會嘗試瞭解你告訴我有關更改此代碼.....我也嘗試將'unins'重命名爲'uninstaller',但我仍然像'uninstaller000.exe'一樣在最後得到三位數字。我怎樣才能刪除'000/001/002 ............ 999'? – GTAVLover

+0

首先閱讀代碼。你明白它的作用嗎?你想如何改變編號邏輯?請記住,您已經省略了許多相關的代碼。我建議你不要太努力。 –

回答

2

我想你至少有非常基本的編程技巧:

將斷點上線UninstallExeFilename:= BaseFilename + '.EXE';

檢查BaseFilename變量在IDE中使用Watch。 這是什麼意思?

它應該是「卸載程序」以符合您的要求。如果不同,他們只需觀察BaseFilename變量並檢查分配給它的值。

將該變量更改爲數字的行可以被註釋掉或修改。

+0

我已經試過了。如前所述,我更改了像'uninstaller'這樣的代碼,但是當我通過舊安裝重新安裝我的程序時,安裝程​​序會告訴我'卸載程序文件退出,請更正問題並重試。'我想要這個代碼('FindFiles procedure')覆蓋'{app}'目錄中現有的'uninstaller.exe' ........... – GTAVLover

+0

Line H:= FindFirstFile(PChar(AddBackslash(BaseDir )+'unins ???。*')搜索現有的卸載程序(使用數字),也可以像'uninstaller。*'一樣更改這個行來忽略uninst000文件 – Slappy

+0

但我仍然收到這個錯誤:'Create Process Failed,該文件存在,代碼:80':(............爲什麼? – GTAVLover