...check if a disk is ready?

Author: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch

Category: Misc

function IsDriveReady(Root: string): Boolean;
var
  
Oem:      Cardinal;
  Dw1, Dw2: DWORD;
begin
  
Oem := SetErrorMode(SEM_FAILCRITICALERRORS);
  if Length(Root) = 1 then Root := Root + ':\';
  Result := GetVolumeInformation(PChar(Root), nil, 0, nil, Dw1, Dw2, nil, 0);
  SetErrorMode(Oem);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if 
IsDriveReady('A') = True then
    
ShowMessage('Drive ready !')
  else
      
ShowMessage('Drive not ready !');
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base