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:
00463412
Views:
17
>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 '\'
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform