Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check if Drive Exist
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00799116
Message ID:
00799121
Views:
21
>Hi All,
>
>Is there any functions in VFP to check if a specific drive? For example, If I don't have H:\ on my pc, I want to display an error message. TIA

Mathew:

The simplest way is to use the WScript.Network drive collection object.
oNet = CREATEOBJECT('WScript.Network')
oDrives = oNet.EnumNetworkDrives
FOR lni = 0 TO oDrives.Count - 1
 ? oDrives.Item(lni), oDrives.Item(lni + 1)
NEXT
Optional the API's GetLogicalDrives function returns an integer that can be parsed to determine whether or not the drive exists.
DECLARE INTEGER GetLogicalDrives IN Win32API
lndrives = GetLogicalDrives()
FOR lni = 0 TO 25
  lcdrive = CHR(65 + lni)
  IF BITTEST(lndrives, lni) THEN
    ? lcdrive + " exists"
  ELSE
    ? lcdrive + " does not exist"
  ENDIF
NEXT
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform