2016-12-16 30 views
1

我想知道如何使用來自自定義嚮導頁面的用戶輸入中的值。我有一個自定義頁面,用戶在其上鍵入ODBC連接數據。這是此部分的代碼:Inno Setup:使用來自注冊表部分中的自定義嚮導頁面的數據

ServerDataPage := CreateInputQueryPage(AskAuthPage.ID, 
    'SQL Server Connection Data', '', 
    'Please insert data...'); 
ServerDataPage.Add('ODBC Name:', False); 
ServerDataPage.Add('Server Name:', False); 
ServerDataPage.Add('User:', False); 
ServerDataPage.Add('Password:', False); 

這是非常有用的,因爲它應該。該頁面隨輸入框和標題一起顯示。

我也查了一個Inno Setup的例子。有這樣一行:

ExamplePage.Values[0] := GetPreviousData('Name', ExpandConstant('{sysuserinfoname}')); 

因此,我認爲必須有一個「落後」的東西,如:

thisIsAVariable := ServerDataPage.Values[x] 

我可以用這些變量來創建這樣一個ODBC?

Root: HKCU; SubKey: Software\ODBC\ODBC.INI\ODBC Data Sources; ValueType: string; ValueName: Leist; ValueData: SQL Server; Flags: createvalueifdoesntexist uninsdeletevalue 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\Leist; Flags: createvalueifdoesntexist uninsdeletevalue; ValueName: Driver; ValueType: string; ValueData: {sys}\SQLSRV32.dll 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\Leist; Flags: createvalueifdoesntexist uninsdeletevalue; ValueName: Server; ValueType: string; ValueData: SERVERADRESS 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\Leist; Flags: createvalueifdoesntexist uninsdeletevalue; ValueName: Database; ValueType: string; ValueData: DATABASE NAME 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\Leist; Flags: createvalueifdoesntexist uninsdeletevalue; ValueName: LastUser; ValueType: string; ValueData: USER 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\Leist; Flags: createvalueifdoesntexist uninsdeletevalue; ValueName: Password; ValueType: string; ValueData: PASSWORD 

如果是這樣,我必須把它放在腳本中?整個「自定義嚮導頁」的東西在[Code]部分。這些變量是否也可以在[Code]部分之外使用?

問候

回答

0

使用scripted constant從在[Registry]部分的自定義頁面(任何其他或)使用的值:

[Registry] 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\ODBC Data Sources; \ 
    ValueType: string; ValueName: Leist; ValueData: SQL Server; \ 
    Flags: createvalueifdoesntexist uninsdeletevalue 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\Leist; \ 
    Flags: createvalueifdoesntexist uninsdeletevalue; ValueName: Driver; \ 
    ValueType: string; ValueData: {sys}\SQLSRV32.dll 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\Leist; \ 
    Flags: createvalueifdoesntexist uninsdeletevalue; ValueName: Server; \ 
    ValueType: string; ValueData: {code:GetServerData|0} 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\Leist; \ 
    Flags: createvalueifdoesntexist uninsdeletevalue; ValueName: Database; \ 
    ValueType: string; ValueData: {code:GetServerData|1} 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\Leist; \ 
    Flags: createvalueifdoesntexist uninsdeletevalue; ValueName: LastUser; \ 
    ValueType: string; ValueData: {code:GetServerData|2} 
Root: HKCU; SubKey: Software\ODBC\ODBC.INI\Leist; \ 
    Flags: createvalueifdoesntexist uninsdeletevalue; ValueName: Password; \ 
    ValueType: string; ValueData: {code:GetServerData|3} 

[Code] 

var 
    ServerDataPage: TInputQueryWizardPage; 

function GetServerData(Param: string): string; 
begin 
    Result := ServerDataPage.Values[StrToInt(Param)]; 
end; 
+0

感謝您的答覆。我測試了你的解決方案,它可以解決工作:(我也檢查過你給我的鏈接,在「ServerDataPageValues ...」之前有一個「ExpandConstant」,但是這對我也有幫助。註冊表項1:1,該變量也存在(否則自定義頁面將工作在所有)。我必須編輯此功能的東西嗎?對不起,我吸入如此糟糕的Inno。:D – aliimagnito

+0

* wouldnt工作在所有 – aliimagnito

+0

*「wouldnt work all at」* - 意思是什麼?它是做什麼的? –

相關問題