Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How many drives?
Message
From
22/02/2017 17:20:40
 
 
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:
01648380
Views:
57
Hi Denis
a quick answer
*available drives on system
cr=chr(13)
local m.x
m.x="Available discs on system :"+chr(13)+chr(13)
for i=97 to 122
  if directory( chr(i)+":\" )
    m.x=m.x+upper(chr(i))+cr
  endif
endfor
messagebox(m.x)
can be done also with APIs
Declare Integer GetLogicalDrives In kernel32
Declare Integer GetDriveType In kernel32 String nDrive

Local nDrivesMask, nIndex, nShift, cDrive,x
nDrivesMask = GetLogicalDrives()


m.x= "Available disk drives/Type:"+Chr(13)+chr(13)

nIndex = 0
Do While .T.
	nShift = Bitlshift(1, nIndex)
	cDrive = Chr(nIndex + 65) + ":"

	If Bitand(nDrivesMask, nShift) = nShift
		m.x=m.x+ Trans(cDrive)+"  "+ Trans(GetDriveType(cDrive))

		Do Case
		Case GetDriveType(cDrive)=0
			m.x=m.x+"  No type"
		Case GetDriveType(cDrive)=2
			m.x=m.x+"  Floppy disk"
		Case GetDriveType(cDrive)=3
			m.x=m.x+"  Hard disk"
		Case GetDriveType(cDrive)=4
			m.x=m.x+" Removable drive or network drive"
		Case GetDriveType(cDrive)=5
			m.x=m.x+" CD-ROM"
		Case GetDriveType(cDrive)=6
			m.x=m.x+" RAM disk(1)"
		Endcase
		m.x=m.x+chr(13)
	Endif

	If nShift > nDrivesMask
		Exit
	Endif

	nIndex = nIndex + 1
Enddo
Messagebox(m.x,0+32+4096,"Discs on system")
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform