Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How many drives?
Message
De
22/02/2017 17:20:40
 
 
À
22/02/2017 16:52:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01648372
Message ID:
01648380
Vues:
59
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")
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform