AGB  ·  Datenschutz  ·  Impressum  







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

COM - For-Each in Delphi, aber wie?

Ein Thema von DelphiPeter · begonnen am 26. Jun 2008 · letzter Beitrag vom 13. Aug 2008
 
nahpets
(Gast)

n/a Beiträge
 
#8

Re: COM - For-Each in Delphi, aber wie?

  Alt 1. Aug 2008, 09:37
Hallo,

ich ahne, was Dein Problem ist, weiß aber keine Lösung.

Eventuell hilft Dir der Auszug aus einem Quelltext von einem meiner Programme:
Delphi-Quellcode:
      wmiObjectSet := wmiServices.InstancesOf(sClass, wbemFlagReturnImmediately or wbemQueryFlagShallow, nil);
      Enum := (wmiObjectSet._NewEnum) as IEnumVariant;
      bOk := False;
      while (Enum.Next(1, ovVar, lwValue) = S_OK) do begin
        bOk := True;
        wmiObject := IUnknown(ovVar) as SWBemObject;
        propSet := wmiObject.Properties_;
        propEnum := (propSet._NewEnum) as IEnumVariant;

        while (propEnum.Next(1, ovVar, lwValue) = S_OK) do begin
          wmiProp := IUnknown(ovVar) as SWBemProperty;
          sValue := '';
          if VarIsNull(wmiProp.Get_Value) then sValue := 'Is Nullelse
          case wmiProp.CIMType of
            wbemCimtypeSint8,
            wbemCimtypeUint8,
            wbemCimtypeSint16,
            wbemCimtypeUint16,
            wbemCimtypeSint32,
            wbemCimtypeUint32,
            wbemCimtypeSint64:
              if VarIsArray(wmiProp.Get_Value) then begin
                if VarArrayHighBound(wmiProp.Get_Value, 1) > 0 then begin
                  for Count := 1 to VarArrayHighBound(wmiProp.Get_Value, 1) do begin
                    sValue := sValue + ' ' + IntToStr(wmiProp.Get_Value[Count]);
                  end;
                end;
              end else sValue := IntToStr(wmiProp.Get_Value);

            wbemCimtypeReal32,
            wbemCimtypeReal64: sValue := FloatToStr(wmiProp.Get_Value);

            wbemCimtypeBoolean: if wmiProp.Get_Value then sValue := 'Trueelse sValue := 'False';

            wbemCimtypeString,
            wbemCimtypeUint64:
              if VarIsArray(wmiProp.Get_Value) then begin
                if VarArrayHighBound(wmiProp.Get_Value, 1) > 0 then begin
                  for Count := 1 to VarArrayHighBound(wmiProp.Get_Value, 1) do begin
                    sValue := sValue + ' ' + wmiProp.Get_Value[Count];
                  end;
                end;
              end else begin
                sValue := wmiProp.Get_Value;
              end;
            wbemCimtypeDatetime:
              sValue := wmiProp.Get_Value;
          else
            begin
              Try
                sValue := wmiProp.Get_Value;
              Except
                on e : Exception Do Begin
                  sValue := 'Wert kann nicht gelesen werden: ' + e.Message;
                end;
              End;
            end;
          end;
          sl.Add(wmiProp.Name + '=' + sValue);
        End;
Mit diesem Teil habe ich jedoch ein Problem, da ist irgendwo ein Speicherloch drin, dass ich nicht finde.
Läuft das Programm lange genug, ist irgendwann der Speicher voll.

Stephan
  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 21:10 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