Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Re: Backup Code using Dynazip.....
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Re: Backup Code using Dynazip.....
Miscellaneous
Thread ID:
00902351
Message ID:
00902351
Views:
56
Hi,

Can anyone improved the code below, I need to get the response on the format dialog if a user select OK to format a disk or just cancel it.

Note: These code mixed from other example by UT members. And you must have a form, class from west-wind, and a Dynazip DLL.
#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.


Jojo R. dela Cuesta
Dalplus Technologies
http://www.dalplus.com
Jojo R. dela Cuesta, B.Sc.
eConsultant, Programmer
Dalplus Technologies
http://www.dalplus.com
Reply
Map
View

Click here to load this message in the networking platform