某些指令值的某些{code:...}
函數被稱爲多次,AppId
就是其中之一。更具體地說,它被稱爲兩次。一次在創建嚮導窗體之前,一次在安裝開始之前。你可以做的只是檢查你試圖從中獲得價值的複選框是否存在。你可以簡單地問一下,如果它是Assigned
如下:
[Setup]
AppId={code:GetAppID}
...
[Code]
var
Ver32RadioButton: TNewRadioButton;
Ver64RadioButton: TNewRadioButton;
function GetAppID(const Value: string): string;
var
AppID: string;
begin
// check by using Assigned function, if the component you're trying to get a
// value from exists; the Assigned will return False for the first time when
// the GetAppID function will be called since even WizardForm not yet exists
if Assigned(Ver32RadioButton) then
begin
AppID := 'FDFD4A34-4A4C-4795-9B0E-04E5AB0C374D';
if Ver32RadioButton.Checked then
Result := AppID + '_32'
else
Result := AppID + '_64';
end;
end;
procedure InitializeWizard;
var
VerPage: TWizardPage;
begin
VerPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
Ver32RadioButton := TNewRadioButton.Create(WizardForm);
Ver32RadioButton.Parent := VerPage.Surface;
Ver32RadioButton.Checked := True;
Ver32RadioButton.Caption := 'Install 32-bit version';
Ver64RadioButton := TNewRadioButton.Create(WizardForm);
Ver64RadioButton.Parent := VerPage.Surface;
Ver64RadioButton.Top := Ver32RadioButton.Top + Ver32RadioButton.Height + 4;
Ver64RadioButton.Caption := 'Install 64-bit version';
end;
謝謝,TLama!我真的不知道這一切,但你通過分享你的知識再一次使我的一天:) – user1662035
不客氣! :-) – TLama