I have an LPTSTR
for a file path, i.e. C:\Program Files\Ahoy
. I would like to convert it to a file://
URL that I can pass to ShellExecute in order to start the system's default browser pointing at the file. I don't want to give the path to ShellExecute directly since file associations may result in it being opened by something other than a web browser. The path is arbitrary, and may contain characters that need to be escaped.
Is there an existing library function, along the lines of Python's urllib.pathname2url, that does this translation? This can be done via the Uri class in .NET, but I haven't found anything for plain win32.