Win32 - 根据文件夹 PIDL 确定文件是否存在于文件夹中的最快方法?
Win32 - Fastest way to determine if file exists in a folder based on a a folders PIDL?
使用 windows/shell api(atl 没问题),给定文件夹的 PIDL,检查该文件夹中是否存在文件的最快方法是什么?
不确定这是否是最快的方式,但它相当简单:
将子文件名的 PIDL
转换为 IShellFolder
(if you don't already have one) using SHGetDesktopFolder()
and IShellFolder::BindToObject()
, or just SHBindToObject()
, or other related function. And then call the folder's IShellFolder::ParseDisplayName()
(and, if needed, IShellFolder::GetAttributesOf()
)。如果出现错误,则文件不存在。
或者,将子文件名的 PIDL
转换为 IShellItem
(if you don't already have one) using SHCreateItemFromIDList()
, and then use SHCreateItemFromRelativeName()
(and, if needed, IShellItem::GetAttributes(SFGAO_VALIDATE)
)。同样,如果发生错误(或属性未验证),则文件不存在。
使用 windows/shell api(atl 没问题),给定文件夹的 PIDL,检查该文件夹中是否存在文件的最快方法是什么?
不确定这是否是最快的方式,但它相当简单:
将子文件名的 PIDL
转换为 IShellFolder
(if you don't already have one) using SHGetDesktopFolder()
and IShellFolder::BindToObject()
, or just SHBindToObject()
, or other related function. And then call the folder's IShellFolder::ParseDisplayName()
(and, if needed, IShellFolder::GetAttributesOf()
)。如果出现错误,则文件不存在。
或者,将子文件名的 PIDL
转换为 IShellItem
(if you don't already have one) using SHCreateItemFromIDList()
, and then use SHCreateItemFromRelativeName()
(and, if needed, IShellItem::GetAttributes(SFGAO_VALIDATE)
)。同样,如果发生错误(或属性未验证),则文件不存在。