我想知道如何使用自定义向导页面中用户输入的值。我有一个自定义页面,用户在其上键入ODBC连接数据。这是这部分的代码:
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 :(得分:1)
使用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;