![]() |
DeviceIoControl dauert lange
Hi,
ich möchte gerne Partitionen daraufhin überprüfen, ob sie ein bestimmtes Dateisystem (nicht FAT oder NTFS) haben. Dazu hab ich mir folgenden Code zusammengebastelt:
Delphi-Quellcode:
Er ist noch nicht ganz fertig, allerdings ist mir aufgefallen, dass das DeviceIoControl manchmal ziemlich lange braucht (bei ca. 4 Laufwerken die überprüft werden müssen, darunter sind Kartenleser, die "nicht bereit" sind, ca. 40s).
const
IOCTL_DISK_GET_DRIVE_GEOMETRY = $00070000; type _DISK_GEOMETRY = packed record Cylinders: Int64; MediaType: Integer; TracksPerCylinder: DWORD; SectorsPerTrack: DWORD; BytesPerSector: DWORD; end; DISK_GEOMETRY = _DISK_GEOMETRY; [...] function IsRightFS(Drive: string): Boolean; var NotUsed, Flags, Bytes: DWORD; DrivePath: string; handle: THandle; dg: DISK_GEOMETRY; begin // Basic check if (GetVolumeInformation(PChar(Drive), nil, 0, nil, NotUsed, Flags, nil, 0)) or (Drive = 'A:\') or (not (GetDriveType(PChar(Drive)) in [DRIVE_FIXED, DRIVE_REMOVABLE])) then Exit(False); DrivePath := '\\.\' + Drive[1] + ':'; handle := CreateFile(PChar(DrivePath), GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, 0); if handle = INVALID_HANDLE_VALUE then Exit(False); if not DeviceIoControl(handle, IOCTL_DISK_GET_DRIVE_GEOMETRY, nil, 0, @dg, SizeOf(DISK_GEOMETRY), bytes, nil) then Exit(False); CloseHandle(handle); Result := True; end; Lässt sich das irgendwie verkürzen? |
Re: DeviceIoControl dauert lange
hoi,
die Funktion GetVolumeInformation liefert doch als 7.parameter das Dateisystem der übergebenen Partition zurück Im moment benutzt du es ja nicht, aber ich vermute du sparst einiges an code wenn du es nutzt ...
Delphi-Quellcode:
cya
GetVolumeInformation(PChar(Drive), nil, 0, nil, NotUsed, Flags, FILESYSTEM, SIZEOF(FILESYSTEM))
EDIT: hab net richtig gelesen --> Zitat:
|
Re: DeviceIoControl dauert lange
Das GetVolumeInformation benutze ich nur, um festzustellen, ob es überhaupt ein Laufwerk mit dem Dateisystem sein kann, um die ganzen restlichen normalen Partitionen schonmal auszuschließen.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:23 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz