홈 · 개발 참고자료

개발 참고자료

[파워빌더] Retrieve the UNC from a mapped drive

작성자
관리자
작성일
2016-10-16
조회
10281
분류
파워빌더
To convert a normal paths (N:\PATH) to UNC (\\SERVER\PATH).[local external function declaration]
FUNCTION ulong WNetGetConnectionA &
( ref string drv, ref string unc, ref ulong buf ) &
LIBRARY "mpr.dll"

[powerscript]
string ls_tmp, ls_unc
Ulong ll_rc, ll_size

ls_tmp = upper(left(as_path,2))
IF right(ls_tmp,1) <> ":" THEN RETURN as_path

ll_size = 255
ls_unc = Space(ll_size)

ll_rc = WNetGetConnectionA (ls_tmp, ls_unc, ll_size)
IF ll_rc = 2250 THEN
// prbably local drive
RETURN as_path
END IF

IF ll_rc <> 0 THEN
MessageBox("UNC Error", &
"Error " + string(ll_rc) + " retrieving UNC for " + ls_tmp)
RETURN as_path
END IF

// Concat and return full path
IF len(as_path) > 2 THEN
ls_unc = ls_unc + mid(as_path,3)
END IF

RETURN ls_unc