AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Finden aller Klassen zur Laufzeit

Ein Thema von tgvoelker · begonnen am 4. Jul 2012 · letzter Beitrag vom 4. Jul 2012
 
tgvoelker

Registriert seit: 9. Sep 2002
Ort: Oelsnitz, Vogtland
44 Beiträge
 
Delphi 12 Athens
 
#7

AW: Finden aller Klassen zur Laufzeit

  Alt 4. Jul 2012, 13:38
Code:
  procedure EnumForms;
  var pAddr:Cardinal;
      pPC:^Cardinal;
      pPS:^ShortString;
      pS,pCN:ShortString;
      pClass:TClass;
      pExcept,pB:Boolean;
  Begin
//nächste Zeile bereitet die Listen vor, zu denen später hinzugefügt wird
    SetUpLists;
    pExcept:=False;
    pAddr:=Cardinal(TObject)+vmtSelfPtr;
    while not pExcept do Begin
      try
        pPC:=Pointer(pAddr);
        if pPC^<>(pAddr-vmtSelfPtr) then Begin Inc(pAddr,4);Continue; End;
        pPC:=Pointer(pAddr-vmtSelfPtr+vmtClassName);
        try
          pPS:=Pointer(pPC^);
        except
          pExcept:=True;
          Continue;
        end;
        try
          pS:=pPS^;
          pClass:=Pointer(pAddr-vmtSelfPtr);
          pCN:=pClass.ClassName;
          pB:=pClass.InheritsFrom(TObject);
        except
          Inc(pAddr,4);
          Continue;
        end;
        if (pCN=pS)and(pB) then Begin
//hier prüfe ich auf Forms und füge die zu best. Listen hinzu. Der Part ist also variabel
          if pClass.InheritsFrom(TForm) And (pClass<>TForm) And (pClass<>TReferenceForm) then Begin
            if pClass.InheritsFrom(TReferenceForm) then PRefFormList.Add(pClass.ClassName);
            PFormList.AddObject(pClass.ClassName,TFormListDesc.Create(TFormClass(pClass)));
          End;
//Ende Prüfung
          pAddr:=Cardinal(pPS)+Length(pS)+1;
          if pAddr mod 4>0 Then pAddr:=((pAddr shr 2) shl 2)+4;
        End Else Inc(pAddr,4);
      except
        pExcept:=True;
      end;
    End;
  End;
Thomas Völker
  Mit Zitat antworten Zitat
 

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:43 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz