// -----------------------------------------------------------------------------------------------------
// This code was generated by the Wmi Delphi Code Creator (WDCC) Version 1.9.9.482
// http://code.google.com/p/wmi-delphi-code-creator/
// Blog http://theroadtodelphi.wordpress.com/wmi-delphi-code-creator/
// Author Rodrigo Ruz V. (RRUZ) Copyright (C) 2011-2015
// -----------------------------------------------------------------------------------------------------
//
// LIABILITY DISCLAIMER
// THIS GENERATED CODE IS DISTRIBUTED "AS IS". NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED.
// YOU USE IT AT YOUR OWN RISK. THE AUTHOR NOT WILL BE LIABLE FOR DATA LOSS,
// DAMAGES AND LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS CODE.
//
// ----------------------------------------------------------------------------------------------------
program GetWMI_Info;
{$APPTYPE CONSOLE}
uses
SysUtils,
ActiveX,
ComObj,
Windows,
Variants;
// Die Klasse "Win32_Volume" stellt einen Speicherbereich auf einer Festplatte
// dar. Die Klasse gibt lokale Volumes wieder, die formatiert, unformatiert,
// bereitgestellt oder offline sind. Ein Volume wird unter Verwendung eines
// Dateisystems, wie z. B. FAT oder NTFS, formatiert, und dem Volume kann eine
// Laufwerkbuchstabe zugewiesen werden. Eine einzelne Festplatte kann mehrere
// Volumes enthalten, und Volumes können über mehrere Datenträger übergreifen. Die
// Klasse "Win32_Volume" unterstützt die Diskettenlaufwerkverwaltung nicht.
procedure GetWin32_VolumeInfo;
const
WbemUser = '
';
WbemPassword = '
';
WbemComputer = '
localhost';
wbemFlagForwardOnly = $00000020;
var
FSWbemLocator: OLEVariant;
FWMIService: OLEVariant;
FWbemObjectSet: OLEVariant;
FWbemObject: OLEVariant;
oEnum: IEnumvariant;
iValue: LongWord;
begin;
FSWbemLocator := CreateOleObject('
WbemScripting.SWbemLocator');
FWMIService := FSWbemLocator.ConnectServer(WbemComputer, '
root\CIMV2', WbemUser, WbemPassword);
FWbemObjectSet := FWMIService.ExecQuery('
SELECT * FROM Win32_Volume', '
WQL', wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum)
as IEnumvariant;
while oEnum.Next(1, FWbemObject, iValue) = 0
do
begin
if pos('
:',
String(FWbemObject.
Name)) > 0
then
begin
Writeln(Format('
Name %s', [
String(FWbemObject.
Name)]));
// String
Writeln(Format('
FileSystem %s', [
String(FWbemObject.FileSystem)]));
// String
Writeln(Format('
Capacity %d', [int64(FWbemObject.Capacity)]));
// Uint64
Case Integer(FWbemObject.DriveType)
of
DRIVE_UNKNOWN:
Writeln('
DriveType Unknown');
DRIVE_REMOVABLE:
Writeln('
DriveType Removable');
DRIVE_FIXED:
Writeln('
DriveType Fixed');
DRIVE_REMOTE:
Writeln('
DriveType Network');
DRIVE_CDROM:
Writeln('
DriveType CD-ROM');
DRIVE_RAMDISK:
Writeln('
DriveType RAM Disk');
end;
Writeln(Format('
FreeSpace %d', [int64(FWbemObject.FreeSpace)]));
// Uint64
Writeln('
-------------------------------------------------------');
End;
FWbemObject := Unassigned;
end;
end;
begin
try
CoInitialize(
nil);
try
GetWin32_VolumeInfo;
finally
CoUninitialize;
end;
except
on E: EOleException
do
Writeln(Format('
EOleException %s %x', [E.
Message, E.ErrorCode]));
on E:
Exception do
Writeln(E.Classname, '
:', E.
Message);
end;
Writeln('
Press Enter to exit');
Readln;
end.