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
Antwort Antwort
nanix
(Gast)

n/a Beiträge
 
#1

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
Gruber_Hans_12345

Registriert seit: 14. Aug 2004
1.441 Beiträge
 
Delphi 2007 Professional
 
#2

AW: WMI (Windows Management Instrumentation) + Demo

  Alt 21. Okt 2016, 15:59
Gibt es für die WMI.pas ein einfaches Beispiel wie man die verwenden kann?
Gruss Hans

2B or not 2B, that is FF
  Mit Zitat antworten Zitat
t.roller
(Gast)

n/a Beiträge
 
#3

AW: WMI (Windows Management Instrumentation) + Demo

  Alt 21. Okt 2016, 16:09
WMI DELPHI CODE CREATOR
WDCC.exe im Anhang
Miniaturansicht angehängter Grafiken
wdcc.jpg  
Angehängte Dateien
Dateityp: zip WDCC.zip (2,47 MB, 41x aufgerufen)
  Mit Zitat antworten Zitat
Gruber_Hans_12345

Registriert seit: 14. Aug 2004
1.441 Beiträge
 
Delphi 2007 Professional
 
#4

AW: WMI (Windows Management Instrumentation) + Demo

  Alt 21. Okt 2016, 17:31
WMI DELPHI CODE CREATOR
WDCC.exe im Anhang
DA bekommt man ja auch Memory Leaks oder?
... werde es mal testen ...
Gruss Hans

2B or not 2B, that is FF
  Mit Zitat antworten Zitat
Gruber_Hans_12345

Registriert seit: 14. Aug 2004
1.441 Beiträge
 
Delphi 2007 Professional
 
#5

AW: WMI (Windows Management Instrumentation) + Demo

  Alt 21. Okt 2016, 17:37
WMI DELPHI CODE CREATOR
WDCC.exe im Anhang
Hmmmm da bekomme ich nur nen RunTime Error, und das wars

[edit]und die zwei demo.exe aus dem ersten Beitrag bringen den Speicherverbruach der exe auch noch oben nach jedem Query
Gruss Hans

2B or not 2B, that is FF

Geändert von Gruber_Hans_12345 (21. Okt 2016 um 17:42 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


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 17: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