I have a requirement to find a UNC path, or a FILE: URL, to a file on
the local machine. The idea is that a remote computer that can see my
shares will be able to use this to access the file on my machine.
For instance, say I have shared my C: drive on my machine WIBBLE with
share name PETE_C, I would like the function, given "c:\users\peterc
\myfile.txt" to return something like "\\WIBBLE\PETE_C\users\peterc
\myfile.txt". A machine on the LAN that could see my machine and had
permission to access my shares could use that path to access the file.
Hopefully, you understand that shares can have a different name to the
drive or directory that is being shared. So that means that you cannot
do a simple-minded translation - you must find out what shares are
available on the machine.
I hoped that WNetGetUniversalName() did what I want, but it doesn't.
It only works if the file is on a drive that is connected to a
*remote* machine. I need an equivalent for where the file is local.
Any pointers would be appreciated.
The share name is normally \\WIBBLE\c$\users\peterc\myfile.txt
(GetComputerName() for WIBBLE)
You don't have to enumerate the shares with WNetEnumResource() and
call
NetShareGetInfo() to get the local name for each share