Consultor Eletrônico



Kbase P93133: How to get the UNC from the letter of the mapped drive?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   30/08/2004
Status: Unverified

GOAL:

How to get the UNC from the letter of the mapped drive?

GOAL:

Can I use external calls to retrive UNC string for a mapped drive letter?

FACT(s) (Environment):

Windows

FIX:

The following sample shows the UNC name for O: mapped drive.

PROCEDURE WNetGetConnectionA EXTERNAL "MPR.DLL" :
DEFINE INPUT PARAMETER lpDrive AS CHAR.
DEFINE OUTPUT PARAMETER lpUNCName AS CHAR.
DEFINE INPUT-OUTPUT PARAMETER lpnLength AS LONG.
DEFINE RETURN PARAMETER iret AS LONG.
END PROCEDURE.

FUNCTION getUNC RETURNS CHAR( INPUT pdrv AS CHAR ):
DEFINE VARIABLE cUNC AS CHAR NO-UNDO.
DEFINE VARIABLE ilen AS INT NO-UNDO INIT 256.
DEFINE VARIABLE iret AS INT NO-UNDO.

cUNC = FILL("x",ilen).
RUN WNetGetConnectionA(pdrv,OUTPUT cUNC, INPUT-OUTPUT ilen,OUTPUT iret).
IF iret = 0 THEN
cUNV = SUBSTRING(cUNC,1,ilen).
ELSE
cUNC = "".

RETURN cUNC.
END FUNCTION.

MESSAGE GETUNC( "O:" ) VIEW-AS ALERT-BOX.