Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To which directory or share is a disk letter mapped?
Message
From
05/07/2008 08:21:23
 
 
To
04/07/2008 21:09:35
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01328956
Message ID:
01329086
Views:
12
>>Thank you for the reference, which is great, especially since it shows in two different ways to accomplish job. I am giving the solution stars to Thomas Bergmann because he came in before you Sergey, not at all any less thanks to you. Lots of savvy people here.
>>
>And for completness sake, here is another code snippet that iterates thru all the drive letters:
>
>
>#Define NO_ERROR	0
>#Define ERROR_NOT_CONNECTED	2250
>
>Declare Integer GetLogicalDriveStrings In win32api;
>	Integer nBufferLength, ;
>	String  @lpBuffer
>
>Declare Integer WNetGetConnection In mpr.Dll;
>	String  lpszLocalName, ;
>	String  @lpszRemoteName, ;
>	Integer @cbRemoteName
>
>Local ;
>	lcLogicalDrives As String, ;
>	lnBufferLen As Integer, ;
>	lnx As Integer, ;
>	lcDrive As String, ;
>	lcRemoteName As String, ;
>	lnResult As Integer
>
>m.lnBufferLen = 128
>m.lcLogicalDrives = Space(m.lnBufferLen)
>
>m.lnBufferLen = GetLogicalDriveStrings(m.lnBufferLen, @m.lcLogicalDrives)
>
>m.lcLogicalDrives = Left(m.lcLogicalDrives, m.lnBufferLen)
>
>Clear
>
>For m.lnx = 1 To m.lnBufferLen Step 4
>	m.lcDrive = Substr(m.lcLogicalDrives, m.lnx, 2)
>	m.lnBufferLen = 2048
>	m.lcRemoteName = Replicate(Chr(0), m.lnBufferLen)
>	m.lnResult = WNetGetConnection(m.lcDrive, @m.lcRemoteName, m.lnBufferLen)
>	m.lcRemoteName = Left(m.lcRemoteName, At(Chr(0), m.lcRemoteName) - 1)
>	Do Case
>	Case m.lnResult = NO_ERROR
>*!* We have a network drive, do stuff here
>		?m.lnResult, m.lcDrive, "Network Drive: ", m.lcRemoteName, Drivetype(m.lcDrive)
>	Case m.lnResult = ERROR_NOT_CONNECTED
>*!* Not a network drive
>		?m.lnResult, m.lcDrive, "Local Drive", Drivetype(m.lcDrive)
>	Otherwise
>*!* Some other error
>		?m.lnResult, m.lcDrive, "Error"
>	Endcase
>Endfor
>
>
>Carlos Alloatti

Gracias, Carlos.

Alex
Previous
Reply
Map
View

Click here to load this message in the networking platform