本文整理汇总了C++中IShellFolder::AddRef方法的典型用法代码示例。如果您正苦于以下问题:C++ IShellFolder::AddRef方法的具体用法?C++ IShellFolder::AddRef怎么用?C++ IShellFolder::AddRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShellFolder
的用法示例。
在下文中一共展示了IShellFolder::AddRef方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doItemMenu
void CFileTreeCtrl::doItemMenu (HWND hwndTreeView, HTREEITEM hItem, LPPOINT pptScreen)
{
TVITEM tvItem;
ZeroMemory(&tvItem, sizeof(tvItem));
tvItem.mask = TVIF_PARAM;
tvItem.hItem = hItem;
if(TreeView_GetItem(hwndTreeView, &tvItem))
{
HWND hwndParent = ::GetParent(hwndTreeView);
HRESULT hr;
CTreeItemInfo* pInfo = (CTreeItemInfo*)tvItem.lParam;
IContextMenu *pcm;
IShellFolder *psfFolder = pInfo->pParentFolder;
if(!psfFolder)
{
SHGetDesktopFolder(&psfFolder);
}
else
{
psfFolder->AddRef();
}
if(psfFolder)
{
hr = psfFolder->GetUIObjectOf( hwndParent,
1,
(LPCITEMIDLIST*)&pInfo->pidlSelf,
IID_IContextMenu,
NULL,
(LPVOID*)&pcm);
if(SUCCEEDED(hr))
{
HMENU hPopup;
hPopup = CreatePopupMenu();
if(hPopup)
{
hr = pcm->QueryContextMenu(hPopup, 0, 1, 0x7fff, CMF_NORMAL | CMF_EXPLORE);
if(SUCCEEDED(hr))
{
IContextMenu2* pcm2;
pcm->QueryInterface(IID_IContextMenu2, (LPVOID*)&pcm2);
UINT idCmd;
idCmd = TrackPopupMenu( hPopup,
TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON,
pptScreen->x,
pptScreen->y,
0,
hwndParent,
NULL);
if(pcm2)
{
pcm2->Release();
pcm2 = NULL;
}
if(idCmd)
{
CMINVOKECOMMANDINFO cmi;
cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
cmi.fMask = 0;
cmi.hwnd = hwndParent;
cmi.lpVerb = (LPCSTR)(INT_PTR)(idCmd - 1);
cmi.lpParameters = NULL;
cmi.lpDirectory = NULL;
cmi.nShow = SW_SHOWNORMAL;
cmi.dwHotKey = 0;
cmi.hIcon = NULL;
hr = pcm->InvokeCommand(&cmi);
}
}
}
pcm->Release();
}
psfFolder->Release();
}
}
}
示例2: SF
ShellFolderWithPidl(IShellFolder * theSF = 0, LPITEMIDLIST thePidl = 0)
: SF(theSF), Pidl(thePidl)
{ if (SF != 0) SF->AddRef(); }
示例3: DoDefault
//***************************************************************************************
void CBCGPShellList::DoDefault (int iItem)
{
LVITEM lvItem;
ZeroMemory(&lvItem, sizeof(lvItem));
lvItem.mask = LVIF_PARAM;
lvItem.iItem = iItem;
if (!GetItem (&lvItem))
{
return;
}
LPBCGCBITEMINFO pInfo = (LPBCGCBITEMINFO) lvItem.lParam;
if (pInfo == NULL || pInfo->pParentFolder == NULL || pInfo->pidlRel == NULL)
{
ASSERT (FALSE);
return;
}
IShellFolder *psfFolder = pInfo->pParentFolder;
if (psfFolder == NULL)
{
SHGetDesktopFolder (&psfFolder);
}
else
{
psfFolder->AddRef ();
}
if (psfFolder == NULL)
{
return;
}
//-----------------------------------------------------
// If specified element is a folder, try to display it:
//-----------------------------------------------------
ULONG ulAttrs = SFGAO_FOLDER;
psfFolder->GetAttributesOf (1,
(const struct _ITEMIDLIST **) &pInfo->pidlRel, &ulAttrs);
if (ulAttrs & SFGAO_FOLDER)
{
DisplayFolder (pInfo);
}
else
{
//-------------------------------
// Invoke a default menu command:
//-------------------------------
IContextMenu *pcm;
HRESULT hr = psfFolder->GetUIObjectOf (GetSafeHwnd (),
1,
(LPCITEMIDLIST*)&pInfo->pidlRel,
IID_IContextMenu,
NULL,
(LPVOID*)&pcm);
if (SUCCEEDED (hr))
{
HMENU hPopup = CreatePopupMenu ();
if (hPopup != NULL)
{
hr = pcm->QueryContextMenu (hPopup, 0, 1, 0x7fff,
CMF_DEFAULTONLY | CMF_EXPLORE);
if (SUCCEEDED (hr))
{
UINT idCmd = ::GetMenuDefaultItem (hPopup, FALSE, 0);
if (idCmd != 0 && idCmd != (UINT)-1)
{
CMINVOKECOMMANDINFO cmi;
cmi.cbSize = sizeof (CMINVOKECOMMANDINFO);
cmi.fMask = 0;
cmi.hwnd = GetParent()->GetSafeHwnd ();
cmi.lpVerb = (LPCSTR)(INT_PTR)(idCmd - 1);
cmi.lpParameters = NULL;
cmi.lpDirectory = NULL;
cmi.nShow = SW_SHOWNORMAL;
cmi.dwHotKey = 0;
cmi.hIcon = NULL;
hr = pcm->InvokeCommand (&cmi);
if (SUCCEEDED (hr) && GetParent () != NULL)
{
GetParent ()->SendMessage (BCGPM_ON_AFTER_SHELL_COMMAND,
(WPARAM) idCmd);
}
}
}
}
pcm->Release ();
}
}
//.........这里部分代码省略.........