Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use of diskspace

Status
Not open for further replies.

annemie

Programmer
Nov 22, 2002
7
BE
I use the function diskspace("A:") to know if a disk is ready or not.
When my colleague uses this function he gets -1 as a result if there is no disk in the drive.
But when I use this function I always get a messagebox with the message : there is no disk in the drive. Please insert disk into drive A:
We both use windows 2000. we both use and vfp 7.

I checked the settings in foxpro and they look the same. How can I avoid this messagebox ?
Why is it showing on my pc and not on another ?
 
annemie,

I get the messagebox as well. I found this old program which does what you want...

Stewart

*- Vladimir Zhuravlev made this function which permits you to check for loaded disk. Try the following code that is created in his class "drv" with the method "testdrive" :
LPARAMETER DriveLet
DECLARE INTEGER GetDiskFreeSpace IN kernel32.DLL ;
STRING @ lpRootPathName, ;
INTEGER @ lpSectorsPerCluster, ;
INTEGER @ lpBytesPerSector, ;
INTEGER @ lpNumberOfFreeClusters, ;
INTEGER @ lpTotalNumberOfClusters

DECLARE INTEGER GetLastError IN kernel32.DLL

DECLARE INTEGER SetErrorMode IN kernel32.DLL INTEGER d

dr=drivelet + ":"
lp=0
lp1=0
lp2=0
lp3=0
d=0x1

=SetErrorMode(d)

IF GetDiskFreeSpace(@dr,@lp,@lp1,@lp2,lp3)=1
=SetErrorMode(0)
RETURN .T.
ELSE
=SetErrorMode(0)
RETURN .F.
ENDIF

*- Then, if we will need to read/write anything from drive, we could put
*- the class on the form and write something like:
*- if thisform.drv.testdrive
*- dr=sys(5)+sys(2001) cd a:
*- Make some operations with read/write and return the value. cd (dr)
*- else
*- =messagebox('Drive is not ready',64,'')
*- endif

*- Additional Comments
* drive available? ready=.Y. ON ERROR DO FLOPPY_AVAIL WITH ready SET DEFAULT TO &gcBDrive && backup drive letter ON ERROR ------------------- PROCEDURE FLOPPY_AVAIL PARAMETERS ready cMessageTitle = 'Drive not ready..'+STR(ERROR()) cMessageText = 'Is the backup disk inserted into drive '+gcBDrive nDialogType = 4 + 32 + 0 * 4 = Yes, No buttons * 32 = Question mark icon * 0 = First button is default nAnswer = MESSAGEBOX(cMessageText, nDialogType, cMessageTitle) * YES=6, NO=7 IF nAnswer = 6 ready=.Y. RETRY ELSE ready=.N. ENDIF ENDPROC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top