使用 Win32/Shell PathCombine() 从 Vista 中的相对获取绝对路径似乎失败 [英] Getting absolute path from relative in Vista seems to fail using Win32/Shell PathCombine()

查看:51
本文介绍了使用 Win32/Shell PathCombine() 从 Vista 中的相对获取绝对路径似乎失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定这是我使用的预期行为还是错误或错误函数,但问题是 PathCombine() 在 Vista 机器上返回错误路径.

Not sure if this is intended behavior or a bug or a wrong function that I'm using, but the problem is that PathCombine() returns a wrong path on a Vista box.

相对路径是(由 WMP 导出到播放列表):

The relative path is (as exported by the WMP to a playlist):

..\..\..\Public\Music\Sample Music\Amanda.wma

它相对的路径是:

C:\Users\userX\Music\Playlists\playlist.wpl

和 PathCombine() 返回:

and PathCombine() returns:

C:\Users\userX\Public\Music\Sample Music\Amanda.wma

但是,该文件实际上位于此处(根据资源管理器以及我无法从代码中打开它的事实来判断):

however, the file is actually located here (judging by the Explorer and the fact that I can't open it from the code):

C:\Users\Public\Music\Sample Music\Amanda.wma

这是一个已知问题吗?我应该使用其他功能吗?

Is this a known issue? Is there some other function I should be using?

推荐答案

PathCombine 文档 指定第二个参数 lpszDir 是指向包含目录路径的最大长度为 MAX_PATH 的空终止字符串的指针."您似乎在目录中传递文件的完全限定名称,而不是目录的完全限定名称.因此,它删除了三个组件:playlist.wpl、Playlists 和 Music,然后附加其余部分.

The documentation for PathCombine specifies that the second parameter, lpszDir, is "A pointer to a null-terminated string of maximum length MAX_PATH that contains the directory path." You appear to be passing the fully qualified name of a file inside the directory, instead of the fully qualified name of the directory. So, it removes three components: playlist.wpl, Playlists, and Music, and then appends the remainder.

您应该能够使用 PathRemoveFileSpec 从您的目录路径中删除文件部分.

You should be able to use PathRemoveFileSpec to remove the file part from your directory path.

这篇关于使用 Win32/Shell PathCombine() 从 Vista 中的相对获取绝对路径似乎失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆