AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte WMI (Windows Management Instrumentation) + Demo
Thema durchsuchen
Ansicht
Themen-Optionen

WMI (Windows Management Instrumentation) + Demo

Ein Thema von himitsu · begonnen am 7. Aug 2006 · letzter Beitrag vom 21. Okt 2016
 
nanix
(Gast)

n/a Beiträge
 
#8

Re: WMI (Windows Management Instrumentation) + Demo

  Alt 11. Jan 2010, 18:43
There is a bug SetLength(_WMIResults.Instance, WMIObjectSet.Count); line 595

when i use it with my code

Delphi-Quellcode:
unit Unit6;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,WMI_Scripting, StdCtrls, ComCtrls;

 const
   Days : array[0..37] of string =
   (
     'Processor',
     'BIOS',
     'SystemSlot',
     'Bus',
     'SystemEnclosure',
     // Motherboard
     'BaseBoard',
     'MotherboardDevice',

     'DMAChannel',
     // Controler
     '1394Controller',
     'IDEController',
     'FloppyController',
     'PCMCIAController',
     'USBController',



     // Drives
     'CDROMDrive',
     'DiskDrive',
     'TapeDrive',

     // Network
     'NetworkAdapter',
     'NetworkAdapterConfiguration',

      // Printer
     'Printer',
     'PrinterConfiguration',


      // Device
      'OnBoardDevice',
      'InfraredDevice',
      'PointingDevice',
      'SoundDevice',
{IRQResource
Keyboard


    PrintJob



ParallelPort


PnPEntity

PortableBattery
PortConnector
PortResource
POTSModem
PowerManagementEvent


Refrigeration
SerialPort
SerialPortConfiguration


SystemEnclosure

SystemSlot    }







     // Memory
     'MemoryArray',
     'MemoryDevice',
     'PhysicalMemory',
     'PhysicalMemory',
     'SMBIOSMemory',
     'PhysicalMemoryArray',
     'SystemMemoryResource',
     'CacheMemory',

     // Graphics
     'DesktopMonitor',
     'DisplayControllerConfiguration',
     'DisplayConfiguration',
     'VideoController',
     'VideoConfiguration',
     'VideoSettings'
     ) ;

type
  TForm6 = class(TForm)
    TreeView1: TTreeView;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  type
  propertys=record
    index:integer;
    name:string;
    Value:String;
  end;

  type
  instance=record
    Index:Integer;
    name:string;
    Propertys: array of Propertys;

  end;

 type
 WMIClass= record
  index:integer;
  name:string;
  Instances:array of instance;
 end;



var
  Form6: TForm6;
  wmi_class:array of WMIClass;
implementation

{$R *.dfm}
 function GetNodeByText
(ATree : TTreeView; AValue:String;
 AVisible: Boolean): TTreeNode;
var
    Node: TTreeNode;
begin
  Result := nil;
  if ATree.Items.Count = 0 then Exit;
  Node := ATree.Items[0];
  while Node <> nil do
  begin
    if UpperCase(Node.Text) = UpperCase(AValue) then
    begin
      Result := Node;
      if AVisible then
        Result.MakeVisible;
      Break;
    end;
    Node := Node.GetNext;
  end;
end;



end;

end;

procedure TForm6.FormCreate(Sender: TObject);
var
i,j:integer;
WMIResults: TWMIInfo;

_Days: Integer;
_Instance:Integer;
_Propertys:Integer;

propertycount:integer;
dayscount:integer;
instancecount:integer;

begin




SetLength(Wmi_class,Length(Days));
for _Days:=0 to Length(Days)-1 do begin

if not WMIGetInfo('.','', '','', 'Win32_'+Days[_Days], WMIResults) then begin
showmessage('error');
Continue;
end;


If WMIResults.Instance = nil Then begin
 wmi_class[_Days].name:=Days[_Days]+' Not Supported';
Continue;
end;


for _Instance := 0 to Length(WMIResults.Instance)-1 do

for _Propertys := 0 to Length(WMIResults.PropName)-1 do begin

dayscount:=Length(Days);
instancecount:=Length(WMIResults.Instance);
propertycount:=Length(WMIResults.PropName);

SetLength(wmi_class[_Days].Instances,instancecount);
SetLength(wmi_class[_Days].Instances[_Instance].Propertys,propertycount);



          wmi_class[_Days].name:=Days[_Days];
          wmi_class[_Days].Instances[_Instance].Name:='Instance '+inttostr(_Instance);
          wmi_class[_Days].Instances[_Instance].Index:=_Instance;
          wmi_class[_Days].Instances[_Instance].Propertys[_Propertys].index:=_Propertys;
          wmi_class[_Days].Instances[_Instance].Propertys[_Propertys].name:=WMIResults.PropName[_Propertys];
          wmi_class[_Days].Instances[_Instance].Propertys[_Propertys].Value:=WMIRead(WMIResults, _Instance, _Propertys);


end;




end;




end;

end.
  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 16:01 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