Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to tell what server a drive is mapped to?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00463131
Message ID:
00464405
Views:
21
Thanks Ed

>>Does anyone know how to tell what server a drive is mapped to?
>>
>>If I have f:\myfiles how do I get the mapping to \\fileserver\files\myfiles
>>
>
>You can use the Win32 API call WNetGetConnection():
>
>
DECLARE INTEGER WNetGetConnection IN WIN32API ;
>   STRING @ lpLocalName, ;
>   STRING @ lpRemoteName, ;
>   INTEGER @ lpnLength
>LOCAL cLocalDevice, cUNCBuffer, nLength
>cLocalDevice = LEFT(FULLPATH(tcPathName),2) + CHR(0)
>cUNCBuffer = REPL(CHR(0),261)
>nLength = LEN(cUNCBuffer)
>IF WNetGetConnection(cLocalDevice, @cUNCBuffer, @nLength) = 0
>   RETURN LEFT(cUNCBuffer,AT(CHR(0),cUNCBuffer)-1)+SUBST(FULLPATH(tcPathName),3)
>ELSE
>   RETURN NULL
>ENDIF
>
>The server is the name between '\\' and the following '\'
For every bug fixed, there is a bigger bug not yet discovered.
Previous
Reply
Map
View

Click here to load this message in the networking platform