R.Wieser
2020-11-26 11:01:06 UTC
Hello all,
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
server, etc.).
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"
tl;dr:
How do I qualify a path using the standard DLLs functions (read: not trying
to check for all bad cases myself) ?
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
server, etc.).
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"
tl;dr:
How do I qualify a path using the standard DLLs functions (read: not trying
to check for all bad cases myself) ?