This article describes getting a UNC path from a mapped network share's drive letter.
Resolution:
Use the Microsoft API WNetGetConnection. This function retrieves the remote name of the network resource associated with a local name. You can obtain this API from here:
http://msdn.microsoft.com/en-us/library/aa922031.aspx
Example (code is also provided as an attachment to this article)
COPY "windows.cpy".
identification division.
SPECIAL-NAMES.
call-convention 74 is STDCALL
call-convention 66 is cc66.
working-storage section.
78 SZ value 25.
01 lpLocalName pic x(5).
01 lpRemoteName pic x(SZ).
01 lpnLength DWORD value sz.
01 proc-pointer procedure-pointer value NULL.
78 MPRdll value "MPR.dll".
01 retDWORD DWORD. *> DWORD = pic 9(9) comp-5
procedure division.
set proc-pointer to entry MPRdll
if proc-pointer = NULL
display "ABNORMAL end: failed to load " MPRdll
stop run
end-if
move z"S:" to lpLocalName
call cc66 WNetGetConnection using lpLocalName
lpRemoteName
lpnLength
returning retDWORD
evaluate retDWORD
when NO-ERROR display "OK " lpLocalName
" <-> "
lpRemoteName(1:lpnLength)
…
MSWNetGetConnection.cbl
Date: Name: Description of change: Date: Name: Description of change: