Changeset 21 for trunk/UPhysDrive.pas
- Timestamp:
- Apr 2, 2016, 11:12:47 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 2 2 lib 3 3 CoolDisk.lps 4 CoolDisk.exe
-
- Property svn:ignore
-
trunk/UPhysDrive.pas
r20 r21 6 6 7 7 uses 8 Classes, SysUtils, Contnrs, UFindFile, UCommon; 8 Classes, SysUtils, Contnrs, UFindFile, UCommon 9 {$IFDEF Windows},ActiveX,ComObj,Variants 10 {$ENDIF}; 9 11 10 12 type … … 29 31 procedure LoadToStrings(Strings: TStrings); 30 32 procedure Detect; 33 private 34 {$IFDEF Windows} 35 procedure GetWin32DiskDriveInfo; 36 {$ENDIF} 31 37 end; 32 38 … … 109 115 end; 110 116 {$ENDIF} 117 {$IFDEF Windows} 118 GetWin32DiskDriveInfo; 119 {$ENDIF} 111 120 // Drive located using filename 112 121 NewDriveInfo := TDriveInfo.Create; … … 120 129 end; 121 130 131 {$IFDEF Windows} 132 procedure TDriveList.GetWin32DiskDriveInfo; 133 const 134 WbemUser = ''; 135 WbemPassword = ''; 136 WbemComputer = 'localhost'; 137 wbemFlagForwardOnly = $00000020; 138 var 139 FSWbemLocator: OLEVariant; 140 FWMIService: OLEVariant; 141 FWbemObjectSet: OLEVariant; 142 FWbemObject: OLEVariant; 143 oEnum: IEnumvariant; 144 OutVar: LongWord; 145 NewDriveInfo: TDriveInfo; 146 begin; 147 FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); 148 FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, 149 WbemPassword); 150 FWbemObjectSet := FWMIService.ExecQuery('SELECT * FROM Win32_DiskDrive', 151 'WQL', wbemFlagForwardOnly); 152 oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; 153 while oEnum.Next(1, FWbemObject, OutVar) = 0 do begin 154 NewDriveInfo := TDriveInfo.Create; 155 NewDriveInfo.Kind := dkPhysical; 156 NewDriveInfo.Model := FWbemObject.Properties_.Item('Caption').Value; 157 //NewDriveInfo.Model := FWbemObject.Properties_.Item('Model').Value; 158 NewDriveInfo.Size := FWbemObject.Properties_.Item('Size').Value; 159 NewDriveInfo.SectorSize := 4096; 160 NewDriveInfo.SectorCount := NewDriveInfo.Size div NewDriveInfo.SectorSize; 161 NewDriveInfo.Path := FWbemObject.Properties_.Item('DeviceID').Value; 162 Add(NewDriveInfo); 163 164 FWbemObject := Unassigned; 165 end; 166 end; 167 {$ENDIF} 168 169 122 170 end. 123 171
Note:
See TracChangeset
for help on using the changeset viewer.