Ich bekomme vom Compiler die Warnung:
Code:
[Warnung] Unit1.pas(254): Variable 'pub' ist möglicherweise nicht initialisiert worden
Es funktionirt ja auch so nur ich möchte eigentlich keine Warnungen haben.
Wie initialisiere ich den eine TStringList?
Geht das nicht mit
pub := TStringList.Create;
?
Delphi-Quellcode:
procedure delphi_versionadd(ort, key: string);
var regist: TRegistry;
pub: TStringList;
pubdir, pubbrc32, pubbrcc32: string;
pubi: integer;
begin
regist := TRegistry.Create;
try
regist.RootKey := HKEY_LOCAL_MACHINE;
pub := TStringList.Create;
regist.OpenKey(ort, false);
regist.GetKeyNames(pub);
regist.CloseKey;
if pub.count > 0 then
begin
for pubi := 0 to pub.count - 1 do
begin
regist.OpenKeyReadOnly(ort + '\' + pub[pubi]);
if regist.ValueExists(key) then
begin
pubdir := regist.ReadString(key);
regist.CloseKey;
pubdir := IncludeTrailingPathDelimiter(pubdir) + 'Bin\';
if FileExists(pubdir + 'brc32.exe') then
pubbrc32 := pubdir + 'brc32.exe';
if FileExists(pubdir + 'brcc32.exe') then
pubbrcc32 := pubdir + 'brcc32.exe';
additem(pub[pubi], pubbrc32, pubbrcc32);
end;
end;
end;
finally
regist.free;
pub.Free;
end;
end;