windows 用于确定路径是相对路径还是绝对路径的 Win32 API?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/853177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Win32 API for determining if a path is relative or absolute?
提问by twk
Is there a win32 function that will tell me if a path is relative or absolute?
是否有一个 win32 函数可以告诉我路径是相对的还是绝对的?
Thanks,
谢谢,
回答by i_am_jorf
回答by NTDLS
As jeffamaphone said: You can use the Shlwapi function PathIsRelative()to determine of a given path is relative or absolute.
正如 jeffamaphone 所说:您可以使用 Shlwapi 函数PathIsRelative()来确定给定的路径是相对的还是绝对的。
But I thought I'd add that you can easily convert a Relative Path to an Absolute Path using _fullpath(), and from an Absolute Path to a Relative Path using PathRelativePathTo().
但是我想我补充一点,你可以使用轻松转换相对路径绝对路径 _fullpath() ,并从绝对路径相对路径使用PathRelativePathTo() 。
Hope this helps!
希望这可以帮助!