|Subject:||problems with qualifying a user-provided path - are there functions available for it ?|
|Posted by:||R.Wieser (addre…@not.available)|
|Date:||Thu, 26 Nov 2020|
Using XPsp3 with its standard DLLs (kernel32, shlwapi, etc) :
I'm trying to make sure that a user-provided path is actually usable, and
I've run into a problem: I can't seem to find DLL functions which do that.
As I need an absolute path I've been trying to use GetFullPathName
(kernel32), but it doesn't even bother to check if the result is
syntactically correct - feeding it something like "file: //
d:\folder\file.ext" (spaces not included) makes it return comething like
"d:\currentpath\file:\d:\folder\file.ext", which is absolutily bogus.
I thought that PathSearchAndQualify (shlwapi) would do the trick, but that
internally just calls GetFullPathName (I've disassembled the function), and
thus does not honor its "AndQualify" name in the least. :-(
As a work-around I've been using PathFileExists (shlwapi), but although that
works it accepts relative paths - and I could not find a function which
would check if the path is absolute (starts with a driveletter, network
To make things even more interresting, I would also like to be able to
qualify things like "%temp%\file.ext" and "D:\%username%\file.ext"
How do I qualify a path using the standard DLLs functions (read: not trying
to check for all bad cases myself) ?