The function needed for this is WNetGetUniversalName. The online help (win32.hlp) says about this function's arguments:
--------------------------------------------------------------------------------
lpBuffer
Points to a buffer that receives the type of data structure specified by the dwInfoLevel parameter.
This data structure has a pointer to a string buffer:
typedef struct _UNIVERSAL_NAME_INFO { /* uni */
LPTSTR lpUniversalName;
} UNIVERSAL_NAME_INFO;
The UNIVERSAL_NAME_INFO structure contains a pointer to a Universal Naming Convention (UNC) name string.
--------------------------------------------------------------------------------
As I found out, this is wrong. In fact, it contains a pointer to itself followed by the string buffer.
Since the pointer takes 4 Bytes, the string starts at Buffer[4].
This piece of code works:
var
cFile,
Buffer : array [0..450] of char;
Size : DWord;
ret : integer;
FileName : string;
..
Size := sizeof(Buffer);
ret := WNetGetUniversalName(StrPCopy(cFile, FileName),
UNIVERSAL_NAME_INFO_LEVEL, @Buffer, Size);
if ret = NO_ERROR then
Result := PChar(@Buffer[4])
else
Result := FileName;