Einzelnen Beitrag anzeigen

w3seek
(Gast)

n/a Beiträge
 
#8

Re: Floppy schreibschutz an oder aus?

  Alt 12. Mär 2004, 22:08
Delphi-Quellcode:
function IsDriveWritable(Drive: Integer): Boolean;
const
  IOCTL_DISK_IS_WRITABLE = (
    ($00000007 shl 16) or (0 shl 14) or
    ($0009 shl 2) or 0);
var
  Device: String;
  hFile: THandle;
  BytesReturned: Cardinal;
begin
  Result := false;
  Device := Format('\\.\%s:', [Char(Drive + 65)]);
  hFile := CreateFile(@Device[1], GENERIC_READ, FILE_SHARE_READ or FILE_SHARE_WRITE, nil,
                      OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  if hFile <> 0 then
  begin
    Result := DeviceIoControl(hFile, IOCTL_DISK_IS_WRITABLE, nil, 0, nil, 0,
                              BytesReturned, nil);
    CloseHandle(hFile);
  end;
end;
ungetestet! hab leider kein Floppylaufwerk hier.
Drive 0 = A:, 1 = B:, 2 = C:, etc...
  Mit Zitat antworten Zitat