Einzelnen Beitrag anzeigen

Benutzerbild von Deltachaos
Deltachaos

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

Re: Was ist an diesen try und except block falsch?

  Alt 1. Mai 2009, 19:07
nun gut.

nur jetzt habe ich mal alles aus den blocks herausgenommen also so:

Delphi-Quellcode:
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
// showmessage('Borland\Delphi');
// 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
// showmessage('CodeGear\BDS');
// 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
// showmessage('Borland\BDS');
// end;

  finally
    regist.free;
  end;
end;
nur der mitlere teil wird immernoch nicht ausgeführt. bzw. bringt kein ergebniss.
Maximilian Ruta
Ich weiß mein Deutsch ist ! Bei Fragen: ich bin fast immer im Mumble
Server: cubexsports.de
Port: 64738
  Mit Zitat antworten Zitat