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.txtifX:is a real drive (i.e. hard disk, USB stick, etc.)\\server\share\foo\bar.txtifX:is a network drive mounted on\\server\shareC:\xyz\foo\bar.txtifX:is the result of aSUBSTcommand 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
SUBSTdrive letter (seeQueryDosDevicewhich 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?