DragDropHandlers IShellExtInit::Initialize 和 NETHOOD UNC 路径

发布于 2024-11-02 17:09:03 字数 638 浏览 6 评论 0原文

我在 HKCR\Folder\shellex\DragDropHandlers 下注册了一个 shell 扩展,我需要在目标文件夹上调用 GetVolumePathName()+GetVolumeInformation() (PIDL 在 IShellExtInit::Initialize)

问题是,当将某些内容放在“Nethood 快捷方式”(My Network Places\sharename)上时,传递给 Initialize 的 PIDL 会引用Nethood 快捷方式而不是 UNC 路径! (在 PIDL 上调用 SHGetPathFromIDList 返回 "%USERPROFILE%\NetHood\SHARE on MACHINE" 而不是像您期望的那样 "\\MACHINE\SHARE"

我也尝试创建PIDL 的 IShellItem 并使用各种 SIGDN 值调用 IShellItem::GetDisplayName,但它们都不返回 UNC 路径。

如何从该 PIDL 获取 UNC 路径?

I have a shell extension registered under HKCR\Folder\shellex\DragDropHandlers and I need to call GetVolumePathName()+GetVolumeInformation() on the target folder (PIDL passed to you in IShellExtInit::Initialize)

The problem is that when something is dropped on a "Nethood shortcut" (My Network Places\sharename) the PIDL passed to Initialize refers to the Nethood shortcut and not the UNC path! (Calling SHGetPathFromIDList on the PIDL returns "%USERPROFILE%\NetHood\SHARE on MACHINE" and not "\\MACHINE\SHARE" like you would expect)

I also tried creating a IShellItem of the PIDL and calling IShellItem::GetDisplayName with various SIGDN values but none of them return the UNC path.

How can I get the UNC path from this PIDL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见 2024-11-09 17:09:03
// error checking omitted
IShellFolder* pFolder = NULL;
LPCITEMIDLIST pidlChild = NULL;
hr = SHBindToParent(pidl, IID_IShellFolder, (void**)&pFolder, &pidlChild);
SFGAOF Attributes = SFGAO_LINK;
hr = pFolder->GetAttributesOf(1, &pidlChild, &Attributes);
if(Attributes & SFGAO_LINK)
{
    // item is a link; get it's target path
    IShellLink* pLink = NULL;
    hr = pFolder->GetUIObjectOf(NULL, 1, &pidlChild, IID_IShellLink, NULL, (void**)&pLink);
    TCHAR szPath[MAX_PATH];
    hr = pLink->GetPath(szPath, MAX_PATH, NULL, 0); // szPath now contains path of UNC share
    pLink->Release();
    pLink = NULL;
}
pFolder->Release();
pFolder = NULL;
// error checking omitted
IShellFolder* pFolder = NULL;
LPCITEMIDLIST pidlChild = NULL;
hr = SHBindToParent(pidl, IID_IShellFolder, (void**)&pFolder, &pidlChild);
SFGAOF Attributes = SFGAO_LINK;
hr = pFolder->GetAttributesOf(1, &pidlChild, &Attributes);
if(Attributes & SFGAO_LINK)
{
    // item is a link; get it's target path
    IShellLink* pLink = NULL;
    hr = pFolder->GetUIObjectOf(NULL, 1, &pidlChild, IID_IShellLink, NULL, (void**)&pLink);
    TCHAR szPath[MAX_PATH];
    hr = pLink->GetPath(szPath, MAX_PATH, NULL, 0); // szPath now contains path of UNC share
    pLink->Release();
    pLink = NULL;
}
pFolder->Release();
pFolder = NULL;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文