1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68:
| procedure TForm1.gethddinfo; Var WMIResults: TWMIInfo; i, i2: Integer; comp, namespace,username, pass,query :String; J: Integer; Begin StringGrid3.DefaultColWidth := StringGrid3.ClientWidth; StringGrid3.RowCount := 1; StringGrid3.ColCount := 1;
comp:='.'; namespace:='root\CIMV2'; username:=''; pass:=''; query:=' SELECT Name, Model, Caption, InterfaceType, MediaType, Size FROM Win32_DiskDrive';
If not WMIGetInfo(comp, namespace, username, pass, Trim(query), WMIResults) Then Begin StringGrid3.Cells[0, 0] := 'ERROR'; Exit; End;
StringGrid3.Cells[0, 0] := '';
If WMIResults.Instance = nil Then Exit;
StringGrid3.DefaultColWidth := Max((StringGrid3.ClientWidth - 20) div (Length(WMIResults.Instance) + 1), 100); StringGrid3.ColCount := Length(WMIResults.Instance) + 1; For i := 0 to Length(WMIResults.Instance) do If i = 0 Then StringGrid3.Cells[i, 0] := 'Instance' Else StringGrid3.Cells[i, 0] := IntToStr(i);
StringGrid3.RowCount := Length(WMIResults.PropName) + 1; StringGrid3.FixedRows := 1; StringGrid3.FixedCols := 1;
For i2 := 0 to High(WMIResults.PropName) do Begin StringGrid3.Cells[0, i2 + 1] := WMIResults.PropName[i2]; For i := 0 to High(WMIResults.Instance) do StringGrid3.Cells[i + 1, i2 + 1] := WMIRead(WMIResults, i, i2); End;
drivesdetected:=Form1.stringgrid3.ColCount - 1; setlength(hddrive, drivesdetected+1); setlength(wmidrives, 5, drivesdetected);
for I := 0 to 4 do for J := 0 to drivesdetected-1 do begin wmidrives[i,j]:=stringgrid3.Cells[i+1,j+1]; end; end;
procedure TForm1.drivedetected(Sender: TObject); begin countletters; aktuelldrives:=drivesdetected; gethddinfo; if aktuelldrives > drivesdetected then begin memo1.lines.add('['+timetostr(time)+'] Neues Laufwerk gefunden'); Timer2.Enabled:=true; end; end; |