#define SEM_FAILCRITICALERRORS 0x0001
#DEFINE SHFMT_ID_DEFAULT 0xFFFF
#DEFINE DRIVE_A 0
*-- SetErrorMode determines whether the system handles
*-- serious errors or whether the program handles them.
DECLARE INTEGER SetErrorMode in win32api INTEGER
*-- SetErrorMode returns what the flags were last set.
lnOldMode = SetErrorMode(SEM_FAILCRITICALERRORS)
*-- Test the FoxPro DISKSPACE() function. If you get a -1, then
*-- there is no disk in the drive.
lnSpace = DISKSPACE("A:",1) &&0
IF lnSpace = -1
MESSAGEBOX("No disk present!",0+64,"Backup to Floppy",1900)
ELSE
* Get Free Space
*!* Case cPath = "A:\"
*!* If Diskspace(cPath)< (RecSize(_File2A)
* totrec + Header(_File2A)+1) *!* Store Diskspace(cPath) to _space
*!* Store Fsize(Allt(_Flsize)) to Flsize
*!* TotSpace = _space/Kb
*!* Filesize = Flsize/Kb
*!* Do Case
*!* Case Thisform.txtpath.value = "A:\"
*!* Messagebox("There's no enough space to handle this Database!"+CHR(13)+;
*!* "You have only "+Allt(Trans(Totspace,'9999999'))
+" Kbytes remaining on this Disk."+CHR(13)+;
*!* "Please insert a blank Diskette in Drive A to continue.",64,'Disk Full')
*!* If Diskspace(cPath)< (RecSize(_File2A)* totrec + Header(_File2A)+1)
*!* Messagebox('No Space for this Data!',64,'',1900)
*!* Retur 0
*!* Endif
*!* Otherwise
*!* Messagebox("The size for this data is "+Allt(Trans(Filesize,'9999999999')) + "Kb !"+CHR(13)+;
*!* "Cannot Backup to this Drive. Please use bigger Removable Storage.",0+64,'Disk Full',1900)
*!* Return 0
*!* Endcase
lnFreeSpace = DISKSPACE("A:", 2)
lcTempName = "A:\" + SYS(2015) + ".tmp"
IF lnFreeSpace > 0
* Try to create a file
lnFH = FCREATE(lcTempName)
IF lnFH < 0
MESSAGEBOX("The disk is write-protected!", 0+16,"Write Protected",2900)
ELSE
= FCLOSE(lnFH)
*/*ERASE (lcTempName)
DECLARE INTEGER SHFormatDrive IN shell32.dll ;
INTEGER hwnd, ;
INTEGER diskID, ;
INTEGER fmtID, ;
INTEGER Option
DECLARE INTEGER GetActiveWindow IN WIN32API
IF SHFormatDrive(GetActiveWindow(), DRIVE_A, SHFMT_ID_DEFAULT, 0) = 0
* It worked
ELSE
* It didn't
Messagebox("Cannot Format. Disk unusable!, Try another one...",0+16,"Format Failed",2900)
RETURN 0
ENDIF
ENDIF
ENDIF
ENDIF
*-- Restore system error handling settings.<PRE>
<PRE> = SetErrorMode(lnOldMode)
thisform.wwIPSTUFF1.Zip2A()
WAIT clear
MESSAGEBOX("Backup Completed!",0+64,"",1900)
CLEAR DLLS
ENDIF
Thanks.