Autor Beitrag
t.roller
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 118
Erhaltene Danke: 34



BeitragVerfasst: So 11.06.17 10:34 
Kurze Version:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
procedure TForm1.Button1Click(Sender: TObject);
const
  WbemUser            ='';
  WbemPassword        ='';
  WbemComputer        ='localhost';
  wbemFlagForwardOnly = $00000020;
var
  FSWbemLocator : OLEVariant;
  FWMIService   : OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject   : OLEVariant;
  oEnum         : IEnumvariant;
  iValue        : LongWord;
  I : Integer;
  Data : array of WORD;
  params: OleVariant;
begin;
    MM('Win32_DiskDrive');
    MM('---------------');
  FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  FWMIService   := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);
  FWbemObjectSet:= FWMIService.ExecQuery('SELECT Model,Capabilities,CapabilityDescriptions,Name FROM
Win32_DiskDrive'
,'WQL',wbemFlagForwardOnly);
  oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
  while oEnum.Next(1, FWbemObject, iValue) = 0 do
  begin
      if not VarIsNull(FWbemObject.Capabilities) then
      begin
        Data := FWbemObject.Capabilities;
        for I:= VarArrayLowBound(data,1to VarArrayHighBound(data,1do
          MM('Capabilities: '+IntToStr(Data[I]));// Array of WORD /Uint16
      end;

      if not VarIsNull(FWbemObject.CapabilityDescriptions) then
      begin
        Params := FWbemObject.CapabilityDescriptions;
        for I:= VarArrayLowBound(Params,1to VarArrayHighBound(Params,1do
          MM('CapabilityDescriptions: '+ VarToStr(Params[I]));// Array of VarToStr
      end;

    MM(Format('Model                %s',[VarToStr(FWbemObject.Model)]));// String
    MM(Format('Name                 %s',[VarToStr(FWbemObject.Name)]));// String
    MM('-------------------------------------------------------------------');
    FWbemObject:=Unassigned;
  end;
end;

Ausgabe:
Win32_DiskDrive
---------------
Capabilities: 3
Capabilities: 4
CapabilityDescriptions: Random Access
CapabilityDescriptions: Supports Writing
Model Intenso External USB 3.0 SCSI Disk Device
Name \\.\PHYSICALDRIVE1
-------------------------------------------------------------------
Capabilities: 3
Capabilities: 4
Capabilities: 10
CapabilityDescriptions: Random Access
CapabilityDescriptions: Supports Writing
CapabilityDescriptions: SMART Notification
Model ST2000LM003 HN-M201RAD
Name \\.\PHYSICALDRIVE0