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!

70 DISKSPACE Fails When Testing CD

Status
Not open for further replies.

xBaseDude

MIS
Jan 31, 2002
357
US
In 60, I had a small routine that would check to see if a CD was inserted in a drive.

If the disk was in, a value of "0" was returned.
If not a value of "-1" indicated the disk was not in drive.

This worked pretty good for me. However....since upgrading to 70, every CD is returning a value of "-1" whether or not a disk is in the drive.

Could I ask someone to confirm this for me?

?DISKSPACE("A:") && works fine
?DISKSPACE("C:") && works fine

?DISKSPACE("E:") && fails && WHERE DRIVE E IS THE CD

Any alts for this new "feature"?

Regards - Wayne


sig_jugler.gif
...all this and tap dancing too!
 
CONFIRMED-

-1 returned even if CD was in drive

Slighthaze = NULL
 
Here's an alternate function for checking


=VolumeInfo("H:\")

Function VolumeInfo(lpRootPathName)

LOCAL nAPIReturn, sMessage, lpVolumeNameBuffer, nVolumeNameSize, lpVolumeSerialNumber, ;
lpMaximumComponentLength, lpFlags, lpFileSystemNameBuffer, nFileSystemNameSize

IF PCOUNT() =0
lpRootPathName = "C:\"
ENDIF

lpVolumeNameBuffer = SPACE(256)
nVolumeNameSize = 256
lpVolumeSerialNumber = 0
lpMaximumComponentLength = 256
lpFlags = 0
lpFileSystemNameBuffer = SPACE(256)
nFileSystemNameSize = 256

DECLARE SHORT GetVolumeInformation IN kernel32;
STRING lpRootPathNamePathName,;
STRING @ lpVolumeNameBuffer,;
INTEGER nVolumeNameSize,;
INTEGER @ lpVolumeSerialNumber,;
INTEGER @ lpMaximumComponentLength,;
INTEGER @ lpFlags,;
STRING @ lpFileSystemNameBuffer,;
INTEGER nFileSystemNameSize

nAPIReturn=GetVolumeInformation(@lpRootPathName, @lpVolumeNameBuffer, ;
nVolumeNameSize, @lpVolumeSerialNumber, ;
@lpMaximumComponentLength, @lpFlags, ;
@lpFileSystemNameBuffer, nFileSystemNameSize )

IF nAPIReturn > 0
sMessage = "Drive name: " + ALLT(lpRootPathName)+CHR(13)+ ;
"Volume Name: " + LEFT(ALLT(lpVolumeNameBuffer),LEN(ALLT(lpVolumeNameBuffer))-1)+CHR(13)+ ;
"Volume Serial #: " + ALLT(STR(lpVolumeSerialNumber))+CHR(13)+ ;
"File System Type: " + LEFT(ALLT(lpFileSystemNameBuffer),LEN(ALLT(lpFileSystemNameBuffer))-1)

MESSAGEBOX(sMessage, "Volume Information")

RETURN 0 &&if File System Type is CDFS then CD is in drive
ELSE
RETURN -1 &&if File System Type is CDFS then CD is not in drive
ENDIF

ENDFUNC


Slighthaze = NULL
 
Slighthaze...thanx am on my way to play w/your coding example!

Mike;
Respectfully questioning if your method doesn't assume Windows Scripting is installed on user's pc?

I have always shy'ed away from using windows scripting because of that, and 2.) Whenever I hear about a nasty windows virus attack or internet DOS attack or email msg bomb...the words "uses Windows Scripting to attach itself", always seems to follow.

I don't want to write code, that will allow virus writers to exploit system weaknesses.

Am I worrying unneccessarily about this?

Regards - Wayne

sig_jugler.gif
...all this and tap dancing too!
 
Wayne,

Yes, you're right - it does assume Windows Scripting Host is installed on the machine. Nowadays, virtually all PCs will have this installed, although I agree that some administrators will disable it because of the security issues that you mentioned.

Mike


Mike Lewis
Edinburgh, Scotland
 
Wayne,
While I can understand administrators disabling .VBS and .JS (script files) default behaviour, I can't see removing WSH. (This would be like diabling macros in Word or Excel, but you wouldn't remove these just because there could be a virus!) In fact, I'm not sure you can actually remove WSH in XP - it's really part of the OS!

Note: You are correct, the behaviour of DISKSPACE() appears to have changed in 7/8 for "removeable" drives, and it appears to be OS dependent! The Hacker's guide recommends that you use DRIVETYPE() and use GetDiskFreeSpaceEx() to get a better result. (I couldn't find an article on that function, but does show an example for GetDiskFreeSpace() ).

Rick
 
Rick;

Not at my main machine right now but....

use GetDiskFreeSpaceEx()

Since I'm testing a CD, I would expect available diskspace to be 0 (zero), same as if the CD was not in the drive.

Regards - Wayne

sig_jugler.gif
...all this and tap dancing too!
 
Wayne,
Because I didn't find any code (yet), I'm assuming you get back an error or unique value when it's a removable drive that's "empty". Otherwise, I don't believe the smart people that wrote the Hacker's Guide would have suggested it!

Rick
 
Rick;

Very happy to report your suggestion worked out quite well!!

Thank-You very much for pointing me in the right direction.

"the smart people that wrote the Hacker's Guide"

I have always had tremendous respect and admiration for Tamar. She always took a lot of time explaining the basics of fp25/26 to me, back in the days of the old Fox Forum on CI$. I look forward to the day when I have a few extra scoots to by her book.

Regards - Wayne

sig_jugler.gif
...all this and tap dancing too!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top