Einzelnen Beitrag anzeigen

Benutzerbild von Deltachaos
Deltachaos

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

Was ist an diesen try und except block falsch?

  Alt 1. Mai 2009, 17:56
Ich weis nicht das ich hier falsch gemacht habe.
Es werden nur die versionen die mit dem erste und dem letzte try und except block ausgelesen werden angezeigt.

währe net wen da wer rüber gugen würde.

Delphi-Quellcode:
uses Registry;

procedure delphi_versions;
var regist: TRegistry;
    pub: TStringList;
    pubdir, pubbrc32, pubbrcc32: string;
    pubi: integer;
begin
  regist := TRegistry.Create;
  try
    regist.RootKey := HKEY_LOCAL_MACHINE;
    try
      pub := TStringList.Create;
      pubdir := '';
      pubbrc32 := '';
      pubbrcc32 := '';
      pubi := 0;
      regist.OpenKey('SOFTWARE\Borland\Delphi', false);
      regist.GetKeyNames(pub);
      regist.CloseKey;
      for pubi := 0 to pub.count - 1 do
      begin
        regist.OpenKeyReadOnly('SOFTWARE\Borland\Delphi\' + pub[pubi]);
        if regist.ValueExists('RootDir') then
        begin
          pubdir := regist.ReadString('RootDir');
          if pubdir[length(pubdir)] = '\then
            pubdir := pubdir + 'Bin\'
          else
            if pubdir[length(pubdir)] = '/then
              pubdir := pubdir + 'Bin/'
            else
              pubdir := 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;
    finally
    end;


    try
      pub := TStringList.Create;
      pubdir := '';
      pubbrc32 := '';
      pubbrcc32 := '';
      pubi := 0;
      regist.OpenKey('SOFTWARE\CodeGear\BDS', false);
      regist.GetKeyNames(pub);
      regist.CloseKey;
      for pubi := 0 to pub.count - 1 do
      begin
        regist.OpenKeyReadOnly('SOFTWARE\CodeGear\BDS\' + pub[pubi]);
        if regist.ValueExists('RootDir') then
        begin
          pubdir := regist.ReadString('RootDir');
          if pubdir[length(pubdir)] = '\then
            pubdir := pubdir + 'Bin\'
          else
            if pubdir[length(pubdir)] = '/then
              pubdir := pubdir + 'Bin/'
            else
              pubdir := 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;
    finally
    end;


    try
      pub := TStringList.Create;
      pubdir := '';
      pubbrc32 := '';
      pubbrcc32 := '';
      pubi := 0;
      regist.OpenKey('SOFTWARE\Borland\BDS', false);
      regist.GetKeyNames(pub);
      regist.CloseKey;
      for pubi := 0 to pub.count - 1 do
      begin
        regist.OpenKeyReadOnly('SOFTWARE\Borland\BDS\' + pub[pubi]);
        if regist.ValueExists('RootDir') then
        begin
          pubdir := regist.ReadString('RootDir');
          if pubdir[length(pubdir)] = '\then
            pubdir := pubdir + 'Bin\'
          else
            if pubdir[length(pubdir)] = '/then
              pubdir := pubdir + 'Bin/'
            else
              pubdir := 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;
    finally
    end;

  finally
    regist.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