First of all, you're not making a hash map, but a pure key value list. There's currently no way to make a real generics hash map in InnoSetup at this time. Anyway, your current code needs a complete refactor. I'd rather write it this way:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
type
TKey = string;
TValue = string;
TKeyValue = record
Key: TKey;
Value: TValue;
end;
TKeyValueList = array of TKeyValue;
function TryGetValue(const KeyValueList: TKeyValueList; const Key: TKey;
var Value: TValue): Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 to GetArrayLength(KeyValueList) - 1 do
if KeyValueList[I].Key = Key then
begin
Result := True;
Value := KeyValueList[I].Value;
Exit;
end;
end;
procedure InitializeWizard;
var
I: Integer;
Value: TValue;
KeyValueList: TKeyValueList;
begin
SetArrayLength(KeyValueList, 3);
for I := 0 to 2 do
begin
KeyValueList[I].Key := 'Key' + IntToStr(I);
KeyValueList[I].Value := 'Value' + IntToStr(I);
end;
if TryGetValue(KeyValueList, 'Key2', Value) then
MsgBox('Value: ' + Value, mbInformation, MB_OK);
end;