From: Paul Jackson Subject: Check for Disk and format if exists. Date: 20 Apr 1999 00:00:00 GMT Message-ID: <7C66DF28FB9ED211B38100105AC95A8E12020C@SV-CNTRMAIL> X-NNTP-Posting-Host: emis-support.demon.co.uk:194.222.188.31 Sender: Paul Jackson References: <371A8743.8DD39D07@unidial.com> <371BCFF6.7A5750F5@idt.net> X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 924609796 nnrp-07:1858 NO-IDENT emis-support.demon.co.uk:194.222.188.31 Newsgroups: borland.public.delphi.vcl.components.writing Use this to check if a disk is in the drive Function FloppyDriveHasDisk(const Drive : Word) : Boolean; var OldErrorMode : Word; begin Result := False; if (Drive = 1) or (Drive = 2) then {is A: or B: floppy disk} begin {turn off errors} OldErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS); Result := not(DiskSize(Drive) = -1); {turn on errors} SetErrorMode(OldErrorMode); end; {if} end; {FloppyDriveHasDisk} Where drive is the index of you drive (A: = 1, B: = 2 ....) -----Original Message----- From: Stephan Marais [mailto:fmarais@idt.net] Posted At: 20 April 1999 01:53 Posted To: writing Conversation: Check for Disk and format if exists. Subject: Re: Check for Disk and format if exists. Hi, I have not tried the following code to do the format, but try it. It calls the windows Format utility: function SHFormatDrive(hWnd : HWnd; Drive, fmtID, Options : Word) :longint; stdcall; external 'shell32.dll'; procedure TForm1.Button1Click(Sender: TObject); begin If SHFormatDrive(Handle, 0, $FFFF, 0) < 0 Then ShowMessage('not work!...'); end; The others options are: $FFFF - Default $0000 - quick format $0001 - full format $0002 - Copy system files regards Stephan Marais Stephen and Stacey wrote: > I am new to Delphi and am looking for a way to check for the existence > of a diskette in drive a: and if it exists format it before writing a > file to it. Does anyone have any suggestions for how to do this? > Thanks in advance for the help!