Einzelnen Beitrag anzeigen

Benutzerbild von Deltachaos
Deltachaos

Registriert seit: 20. Feb 2008
Ort: Berlin
195 Beiträge
 
Delphi 7 Personal
 
#1

TStringList initialisieren! Wie?

  Alt 2. Mai 2009, 12:38
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;
Maximilian Ruta
Ich weiß mein Deutsch ist ! Bei Fragen: ich bin fast immer im Mumble
Server: cubexsports.de
Port: 64738
  Mit Zitat antworten Zitat