(* Collection of code snippets by Arne Vajhøj *)
(* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) *)
program wmifun2;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  ActiveX,
  Variants,
  WbemScripting_TLB in '..\..\Program Files\Borland\Delphi7\Projects\WbemScripting_TLB.pas';

var
  loc : ISWbemLocator;
  serv : ISWbemServices;
  objset : ISWbemObjectSet;
  enum : IEnumVariant;
  temp : OleVariant;
  val : Cardinal;
  obj : ISWbemObject;
  prop : ISWbemProperty;
  caption, drivetype, size : OleVariant;
  i : integer;

begin
  CoInitialize(nil);
  loc := CoSWbemLocator.Create;
  serv :=  loc.ConnectServer('.', 'root\cimv2', '', '', '','', 0, nil);
  objset := serv.ExecQuery('SELECT * FROM Win32_LogicalDisk', 'WQL', wbemFlagReturnImmediately and wbemFlagForwardOnly , nil);
  enum := (objset._NewEnum) as IEnumVariant;
  while (enum.Next(1, temp, val) = S_OK) do begin
    obj := IUnknown(temp) as ISWBemObject;
    prop := obj.Properties_.Item('Caption', 0);
    caption := prop.Get_Value;
    prop := obj.Properties_.Item('DriveType', 0);
    drivetype := prop.Get_Value;
    prop := obj.Properties_.Item('Size', 0);
    size := prop.Get_Value;
    writeln(VarToStr(caption),' ',VarToStr(drivetype),' ',VarToStr(size));
  end;
  CoUninitialize();
end. 
