I wonder if there is a universal way of resolving a path using a drive letter (such as X:\foo\bar.txt
) into its equivalent UNC path, which might be one of the following:
X:\foo\bar.txt
ifX:
is a real drive (i.e. hard disk, USB stick, etc.)\\server\share\foo\bar.txt
ifX:
is a network drive mounted on\\server\share
C:\xyz\foo\bar.txt
ifX:
is the result of aSUBST
command mappingX:
toC:\xyz
I know that there are partial solutions which will:
Resolve a network drive (see for instance question 556649 which relies on
WNetGetUniversalName
)Resolve the
SUBST
drive letter (seeQueryDosDevice
which works as expected, but does not return UNC paths for things such as local drives or network drives).
Am I missing some straightforward way of implementing this drive letter resolution in Win32? Or do I really have to mess with both WNetGetUniversalName
and QueryDosDevice
to get what I need?