Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Thread Tools Display Modes
Old 01-26-2000, 06:33 AM
Posts: n/a
Default How can i know if there is disk in drive?

I have a programs that needs to read data from floppy disk and CD's!

every time i try to read and there is no disk or diskette i get I/O error!!!

how can i indicate if there is disk in the drive?
Reply With Quote
Old 01-26-2000, 10:20 AM
Posts: n/a
Default RE: How can i know if there is disk in drive?

One way that I've found that works is to use the Windows API call GetVolumeInformation to test if a drive is ready. GetVolumeInformation will retrieve information like serial numbers and disk pacities. If GetVolumeInformation can read a drive it returns true, otherwise it returns false. I've written a wrapper function that will help you out with your problem:

procedure TForm1.Button1Click(Sender: TObject);


* *if CheckDriveOK('f: ') = False then

* * * *ShowMessage('Drive Not Ready')

* *else

* * * *ShowMessage('Drive is Fine');


function TForm1.CheckDriveOK(Drv : String) : Boolean;


//Volume Information Variables

* *nVNameSer * : PDWORD;

* *pVolName * *: PChar;

* *FSSysFlags,

* *maxCmpLen * : DWord;

* *pFSBuf * * *: PChar;


//initialize vars

* *GetMem(pVolName, MAX_PATH);

* *GetMem(pFSBuf, MAX_PATH);

* *GetMem(nVNameSer, MAX_PATH);

//Now, get the volume information

* *Result := GetVolumeInformation(PChar(drv), pVolName, MAX_PATH, nVNameSer, maxCmpLen, FSSysFlags, pFSBuf, MAX_PATH);


Written by Brendan Delumpa on 11/4/98

This code was found at:
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

All times are GMT. The time now is 07:25 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.