2015-12-07 35 views
3

是否可以使用代碼更改[Messages]部分中的消息? 我想更改消息ConfirmUninstall,如下所示。更改卸載確認提示

[Messages] 
ConfirmUninstall=Are you sure you want to remove {code:GetIDandName} and its components. 

是否可以這樣做?如果不是,有沒有辦法實現這一目標?

謝謝。

回答

3

不,你不能。

在某些情況下,您可能可以使用a preprocessor

但不是在你的情況。

您可以自動化界面,但它不好。請參閱Inno Setup - Automatically submitting uninstall prompts


所有你可以用ConfirmUninstall做的是:

[Setup] 
AppId=myprogram 

[Code] 

const 
    UninstallKey = 
    'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#SetupSetting("AppId")}_is1'; 
    UninstallStringName = 'UninstallString'; 
    CustomUninstallPromptSwitch = '/CUSTOMUNINSTALLPROMPT'; 
    UninstallSwitches = '/SILENT ' + CustomUninstallPromptSwitch; 

procedure CurStepChanged(CurStep: TSetupStep); 
var 
    S: string; 
begin 
    if CurStep = ssPostInstall then 
    begin 
    if not RegQueryStringValue(
      HKEY_LOCAL_MACHINE, ExpandConstant(UninstallKey), 
      UninstallStringName, S) then 
    begin 
     Log(Format(
      'Cannot find %s in %s', [ 
      UninstallStringName, ExpandConstant(UninstallKey)])); 
    end 
     else 
    begin 
     Log(Format('%s is %s', [UninstallStringName, S])); 
     S := S + ' ' + UninstallSwitches; 
     if not RegWriteStringValue(
       HKEY_LOCAL_MACHINE, ExpandConstant(UninstallKey), 
       UninstallStringName, S) then 
     begin 
     Log(Format('Error writting %s', [UninstallStringName])); 
     end 
     else 
     begin 
     Log(Format('Written [%s] to %s', [S, UninstallStringName])); 
     end; 
    end; 
    end; 
end; 

function CmdLineParamExists(const Value: string): Boolean; 
var 
    I: Integer; 
begin 
    Result := False; 
    for I := 1 to ParamCount do 
    begin 
    if CompareText(ParamStr(I), Value) = 0 then 
    begin 
     Result := True; 
     Exit; 
    end; 
    end; 
end; 

function GetIDandName: string; 
begin 
    Result := ...; 
end; 

function InitializeUninstall(): Boolean; 
var 
    Text: string; 
begin 
    Result := True; 

    if CmdLineParamExists(CustomUninstallPromptSwitch) and UninstallSilent then 
    begin 
    Log('Custom uninstall prompt'); 
    Text := FmtMessage(SetupMessage(msgConfirmUninstall), [GetIDandName()]); 
    Result := (MsgBox(Text, mbConfirmation, MB_YESNO) = IDYES); 
    end; 
end; 

你甚至可以更進一步,並禁止卸載程序來進行,當與自定義開關不執行。這樣您可以防止用戶手動從安裝文件夾啓動unins000.exe

+0

GetIDandName只是返回一個我想用的字符串,而不是默認的%1。 – ababeel

+0

當然,但是字符串的來源是什麼?你如何生產這條繩?你能告訴我們代碼嗎? –

+0

我的道歉不是更具描述性。基本上使用安裝程序,我可以安裝應用程序的多個實例,每個應用程序具有唯一的名稱/ ID。它存儲在註冊表中。所以我有GetIDandName()函數,它基本讀取註冊表並返回字符串。 – ababeel