Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use the <a href="http://msdn.microsoft.com/en-us/library/aa394582%28VS.85%29.aspx" rel="nofollow noreferrer">WMI</a> class <a href="http://msdn.microsoft.com/en-us/library/aa394132%28VS.85%29.aspx" rel="nofollow noreferrer">Win32_DiskDrive</a>. if you need get info about the logical drive you can query the wmi with something like this</p> <pre><code>Select * Win32_LogicalDisk where DriveType = 2 </code></pre> <p>to access the <a href="http://msdn.microsoft.com/en-us/library/aa394582%28VS.85%29.aspx" rel="nofollow noreferrer">WMI</a> from delphi you must import the Microsoft WMIScripting V1.x Library using Component->Import Component->Import type library->Next->"Select the library"->Next->Add unit to project->Finish.</p> <p>if you need more info about usb devices you can check also the next classes</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/aa394505%28VS.85%29.aspx" rel="nofollow noreferrer">Win32_USBControllerDevice</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/aa394353%28VS.85%29.aspx" rel="nofollow noreferrer">Win32_PnPEntity</a></li> </ul> <p>See this example (tested in Delphi 2007 and Windows 7)</p> <pre><code>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. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload