Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How many drives?
Message
From
22/02/2017 17:11:53
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
22/02/2017 16:52:27
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01648372
Message ID:
01648377
Views:
83
Likes (1)
>I want to know what are the drives in my computer. Perhaps there's a vfp function that would tell me that but I don't remember.
	ofso=createobject("scripting.filesystemobject")
*!*	* Enumerate CD-ROMs, removable drives and Floppy
	loDrives = EnumerateDrivesEx("ALL")

*-----------------------------------------
function EnumerateDrivesEx
	lparameters tcTypes2Return
* tcTypes2Return - a list of drive types to return. ALL is default
	local lcTypeList, loDrives as collection, lnI, lnDriveType, lcDriveType, lcTypes2Return, loShellApp, lcTypeExtended

	lcTypes2Return 	= upper(evl(tcTypes2Return, "ALL"))
	loDrives		= createobject("Collection")
	lcTypeList		= "UNKNOWN,REMOVABLE,FIXED,NETWORK,CDROM,RAMDISK"
	loShellApp = createobject("Shell.Application")

	for lnI = asc("A") to asc("Z")
		lnDriveType = drivetype(chr(lnI))
		if between(lnDriveType, 2, 6)
			lcDriveType = getwordnum(lcTypeList, lnDriveType, [,])
			if lcDriveType == "REMOVABLE"  ;
					and "FLOPPY" $ upper(loShellApp.NameSpace(chr(lnI)+ ":").self.type)
				lcDriveType = "FLOPPY"
			endif
			if lcTypes2Return = "ALL" or (lcDriveType $ lcTypes2Return)
				loDrives.add(lcDriveType, chr(lnI)+":")
			endif
		endif
	endfor
	return loDrives

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform