Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Detect If a Drive Is Ready

delphi removable drive drive ready windows

  • Please log in to reply
No replies to this topic

#1 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts
  • Programming Language:PHP, Delphi/Object Pascal, Pascal, Transact-SQL
  • Learning:C, Java, PHP

Posted 17 February 2013 - 08:10 AM

Use the following function if you need to check whether a drive is ready. Great for checking those drives with removable media.

 

 
uses ..., Windows, ..;
 
function IsDriveReady(ADrive: string): Boolean;
var
  vOem   : DWORD;
  Dw1,Dw2: DWORD;
begin
  vOem := SetErrorMode(SEM_FAILCRITICALERRORS);
  try
    if Length(ADrive) = 1 then ADrive := ADrive + ':\';
    Result := GetVolumeInformation(Pointer(ADrive), nil, 0, nil, Dw1, Dw2, nil, 0);
  finally
    SetErrorMode(vOem);
  end;
end;

Edited by LuthfiHakim, 22 February 2013 - 01:16 AM.

  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download