16,548
社区成员




void CRightKeyMenuDlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
//CDialogEx::OnOK();
IShellFolder *pIShellFolder = NULL;
HRESULT hr = SHGetDesktopFolder(&pIShellFolder);
if(NOERROR != hr)
{
return;
}
WCHAR* FilePath = TEXT("D:\\Program Files\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv.exe");
LPITEMIDLIST pidl;
ULONG cbEaten;
DWORD dwAttribs = SFGAO_COMPRESSED;
hr = pIShellFolder->ParseDisplayName(NULL, NULL, FilePath, &cbEaten, &pidl, &dwAttribs);
if(S_OK != hr)
{
return;
}
IShellFolder *psfParent;
LPCITEMIDLIST pidlRelative = NULL;
hr = SHBindToParent(pidl, IID_IShellFolder, (void**)&psfParent, &pidlRelative);
if(S_OK != hr)
{
return;
}
CMenu mu;
mu.CreatePopupMenu();
LPCONTEXTMENU ppv = NULL;
pIShellFolder->GetUIObjectOf(NULL, 1, &pidlRelative, IID_IContextMenu, NULL, (void**)&ppv);
ppv->QueryContextMenu(mu.m_hMenu, mu.GetMenuItemCount(), 0, 10000, CMF_NORMAL | CMF_EXPLORE);
int i= mu.GetMenuItemCount();
POINT pt;
GetCursorPos(&pt);
mu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x,pt.y,AfxGetApp()-> GetMainWnd());
}