WMI 클래스 Win32_DiskDrive을 사용할 수 있습니다. 논리 드라이브에 대한 정보를 얻을 필요하면 당신은> 가져 오기는 마이크로 소프트 WMIScripting V1.x 라이브러리 컴포넌트 -> 가져 오기 컴포넌트 -를 사용하여 가져와야합니다 델파이에서 WMI 액세스하려면이
Select * Win32_LogicalDisk where DriveType = 2
같은과 WMI를 조회 할 수 있습니다 타입 라이브러리 -> 다음 -> "라이브러리 선택"-> 다음 -> 프로젝트에 유닛 추가 -> 마침.
당신은 당신이 다음 클래스
(델파이 2007 및 Windows 7에서 테스트)이 예를 참조
도 확인할 수있는 USB 장비에 관한 더 많은 정보를 필요로하는 경우
program GetWMI_USBConnectedInfo;
{$APPTYPE CONSOLE}
uses
Classes,
ActiveX,
Variants,
SysUtils,
WbemScripting_TLB in '..\..\..\Documents\RAD Studio\5.0\Imports\WbemScripting_TLB.pas';
procedure GetUSBDiskDriveInfo;
var
WMIServices : ISWbemServices;
Root : ISWbemObjectSet;
Item : Variant;
i : Integer;
StrDeviceUSBName: String;
begin
WMIServices := CoSWbemLocator.Create.ConnectServer('.', 'root\cimv2','', '', '', '', 0, nil);
Root := WMIServices.ExecQuery('Select * From Win32_DiskDrive Where InterfaceType="USB"','WQL', 0, nil);//more info in http://msdn.microsoft.com/en-us/library/aa394132%28VS.85%29.aspx
for i := 0 to Root.Count - 1 do
begin
Item := Root.ItemIndex(i);
Writeln('Caption '+VarToStr(Item.Caption));
Writeln('DeviceID '+VarToStr(Item.DeviceID));
Writeln('FirmwareRevision '+VarToStr(Item.FirmwareRevision));
Writeln('Manufacturer '+VarToStr(Item.Manufacturer));
Writeln('Model '+VarToStr(Item.Model));
Writeln('PNPDeviceID '+VarToStr(Item.PNPDeviceID));
Writeln('Status '+VarToStr(Item.Status));
End;
end;
begin
try
CoInitialize(nil);
GetUSBDiskDriveInfo;
Readln;
CoUninitialize;
except
on E:Exception do
Begin
CoUninitialize;
Writeln(E.Classname, ': ', E.Message);
Readln;
End;
end;
end.
답변을 수락 하시길 바랍니다. –