PROCEDURE GetUNCPath LPARAMETERS tcPath LOCAL lcResult, lcRemoteDevice, lcBuffer, lnSize, lnError lcResult = "" lcBuffer = SPACE(200) + CHR(0) lnSize = LEN(lcBuffer) *------------------------------------------------------------------- *-- If the user passed in only one character, this will make sure *-- the value is correct. *------------------------------------------------------------------- lcRemoteDevice = LEFT(tcPath,1) + ":" *------------------------------------------------------------------- *-- Add CHR(0) to the end of the string. This will make finding the *-- end of the return value easier to find. *------------------------------------------------------------------- IF RIGHT(lcRemoteDevice, 1) # CHR(0) lcRemoteDevice = lcRemoteDevice + CHR(0) ENDIF *------------------------------------------------------------------- *-- Open the API function *------------------------------------------------------------------- DECLARE INTEGER WNetGetConnection IN Win32API ; STRING @lcRemoteDevice, STRING @lcBuffer, ; INTEGER @lnSize *------------------------------------------------------------------- *-- Send it in and get the return values *------------------------------------------------------------------- lnError = WNetGetConnection(@lcRemoteDevice, @lcBuffer, @lnSize) IF lnError = 0 lcResult = LEFT(lcBuffer, AT(CHR(0), lcBuffer) - 1) *------------------------------------------------------------------- *-- I just want the machine name and volume [share name] *------------------------------------------------------------------- IF AT("\", lcResult, 4) > 0 lcResult = SUBSTR(lcResult, 1, AT("\", lcResult, 4) - 1) ENDIF ENDIF RETURN lcResult ENDPROC PROCEDURE CreateDriveMapping LPARAMETERS tcDrive, tcUNC IF VARTYPE(tcDrive) <> "C" OR EMPTY(tcDrive) RETURN .F. ENDIF IF VARTYPE(tcUNC) <> "C" OR EMPTY(tcUNC) RETURN .F. ENDIF IF NOT DIRECTORY(tcUNC) RETURN .F. ENDIF tcDrive = LEFT(tcDrive, 1) + [:] IF DIRECTORY(tcDrive) RETURN .T. && or .F., your decision ENDIF DECLARE INTEGER WNetAddConnection IN WIN32API ; STRING @lpszRemoteName, STRING @lpszPassword, STRING @lpszLocalName lnRetVal = WNetAddConnection(@tcUNC, 0, @tcDrive) RETURN (lnRetVal = 0) ENDPROC PROCEDURE RemoveDriveMapping LPARAMETERS tcDrive IF VARTYPE(tcDrive) <> 'C' OR EMPTY(tcDrive) RETURN .F. ENDIF IF DRIVETYPE(tcDrive) <> 4 RETURN .F. ENDIF LOCAL lnForce, lnRetVal DECLARE INTEGER WNetCancelConnection IN "mpr.dll" ; STRING tcDrive, ; INTEGER lnForce lnForce = 1 && Force the disconnect, even if files are open lnRetVal = WNetCancelConnection(tcDrive, lnForce) RETURN (lnRetVal = 0) ENDPROC>GETDIR() doesn't return remoted mapped drives that are mapped, but not connected, as illustrated by their icon having a red X thru it in Explorer. This happens when the computer is started before the computer with the mapping is started before the computer with the drive.