本文整理汇总了C++中IShellFolder::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IShellFolder::Release方法的具体用法?C++ IShellFolder::Release怎么用?C++ IShellFolder::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShellFolder
的用法示例。
在下文中一共展示了IShellFolder::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetComputerNameFromIDList
DWORD Network::GetComputerNameFromIDList(LPITEMIDLIST lpiil,LPSTR szName,DWORD dwBufferLen)
{
// May be computer?
IShellFolder *psf;
if (!SUCCEEDED(SHGetDesktopFolder(&psf)))
return 0;
SHDESCRIPTIONID di;
if (!SUCCEEDED(SHGetDataFromIDList(psf,lpiil,SHGDFIL_DESCRIPTIONID,&di,sizeof(SHDESCRIPTIONID))))
{
psf->Release();
return 0;
}
if (di.clsid!=CLSID_NetworkPlaces)
{
psf->Release();
return 0;
}
STRRET str;
if (!SUCCEEDED(psf->GetDisplayNameOf(lpiil,SHGDN_FORPARSING,&str)))
{
psf->Release();
return 0;
}
psf->Release();
if (ShellFunctions::StrRetToStr(str,lpiil,szName,dwBufferLen))
return istrlen(szName);
return 0;
}
示例2: do_context_menu
HRESULT Entry::do_context_menu(HWND hwnd, const POINT& pos, CtxMenuInterfaces& cm_ifs)
{
ShellPath shell_path = create_absolute_pidl();
LPCITEMIDLIST pidl_abs = shell_path;
if (!pidl_abs)
return S_FALSE; // no action for registry entries, etc.
#ifdef USE_MY_SHBINDTOPARENT
IShellFolder* parentFolder;
LPCITEMIDLIST pidlLast;
// get and use the parent folder to display correct context menu in all cases -> correct "Properties" dialog for directories, ...
HRESULT hr = my_SHBindToParent(pidl_abs, IID_IShellFolder, (LPVOID*)&parentFolder, &pidlLast);
if (SUCCEEDED(hr)) {
hr = ShellFolderContextMenu(parentFolder, hwnd, 1, &pidlLast, pos.x, pos.y, cm_ifs);
parentFolder->Release();
}
return hr;
#else
static DynamicFct<HRESULT(WINAPI*)(LPCITEMIDLIST, REFIID, LPVOID*, LPCITEMIDLIST*)> SHBindToParent(TEXT("SHELL32"), "SHBindToParent");
if (SHBindToParent) {
IShellFolder* parentFolder;
LPCITEMIDLIST pidlLast;
// get and use the parent folder to display correct context menu in all cases -> correct "Properties" dialog for directories, ...
HRESULT hr = (*SHBindToParent)(pidl_abs, IID_IShellFolder, (LPVOID*)&parentFolder, &pidlLast);
if (SUCCEEDED(hr)) {
hr = ShellFolderContextMenu(parentFolder, hwnd, 1, &pidlLast, pos.x, pos.y, cm_ifs);
parentFolder->Release();
}
return hr;
} else {
/**@todo use parent folder instead of desktop folder
Entry* dir = _up;
ShellPath parent_path;
if (dir)
parent_path = dir->create_absolute_pidl();
else
parent_path = DesktopFolderPath();
ShellPath shell_path = create_relative_pidl(parent_path);
LPCITEMIDLIST pidl = shell_path;
ShellFolder parent_folder = parent_path;
return ShellFolderContextMenu(parent_folder, hwnd, 1, &pidl, pos.x, pos.y);
*/
return ShellFolderContextMenu(GetDesktopFolder(), hwnd, 1, &pidl_abs, pos.x, pos.y, cm_ifs);
}
#endif
}
示例3: SetObjects
void CShellContextMenu::SetObjects(const QStringList &strList)
{
// free all allocated datas
if (m_psfFolder && bDelete)
m_psfFolder->Release ();
m_psfFolder = NULL;
FreePIDLArray (m_pidlArray);
m_pidlArray = NULL;
// get IShellFolder interface of Desktop (root of shell namespace)
IShellFolder * psfDesktop = NULL;
SHGetDesktopFolder (&psfDesktop); // needed to obtain full qualified pidl
// ParseDisplayName creates a PIDL from a file system path relative to the IShellFolder interface
// but since we use the Desktop as our interface and the Desktop is the namespace root
// that means that it's a fully qualified PIDL, which is what we need
LPITEMIDLIST pidl = NULL;
psfDesktop->ParseDisplayName (NULL, 0, (LPOLESTR)strList[0].utf16(), NULL, &pidl, NULL);
// now we need the parent IShellFolder interface of pidl, and the relative PIDL to that interface
LPITEMIDLIST pidlItem = NULL; // relative pidl
SHBindToParentEx (pidl, IID_IShellFolder, (void **) &m_psfFolder, NULL);
free (pidlItem);
// get interface to IMalloc (need to free the PIDLs allocated by the shell functions)
LPMALLOC lpMalloc = NULL;
SHGetMalloc (&lpMalloc);
lpMalloc->Free (pidl);
// now we have the IShellFolder interface to the parent folder specified in the first element in strArray
// since we assume that all objects are in the same folder (as it's stated in the MSDN)
// we now have the IShellFolder interface to every objects parent folder
IShellFolder * psfFolder = NULL;
nItems = strList.size ();
for (int i = 0; i < nItems; i++)
{
pidl=0;
psfDesktop->ParseDisplayName (NULL, 0, (LPOLESTR)strList[i].utf16(), NULL, &pidl, NULL);
if (pidl)
{
m_pidlArray = (LPITEMIDLIST *) realloc (m_pidlArray, (i + 1) * sizeof (LPITEMIDLIST));
// get relative pidl via SHBindToParent
SHBindToParentEx (pidl, IID_IShellFolder, (void **) &psfFolder, (LPCITEMIDLIST *) &pidlItem);
m_pidlArray[i] = CopyPIDL (pidlItem); // copy relative pidl to pidlArray
free (pidlItem);
lpMalloc->Free (pidl); // free pidl allocated by ParseDisplayName
psfFolder->Release ();
}
}
lpMalloc->Release ();
psfDesktop->Release ();
bDelete = TRUE; // indicates that m_psfFolder should be deleted by CShellContextMenu
}
示例4: FillItemVector
void FillItemVector()
{
// 1. Desktop
#ifdef SUPPORT_CURFOLDER_AS_ITEM
ShellFolderWithPidl aDesktop;
SHGetDesktopFolder(&aDesktop.SF);
SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &aDesktop.Pidl);
myItems.push_back( aDesktop );
#else
myItems.push_back( new ShellFolder(CSIDL_DESKTOP) );
#endif
// 2. Others
if (myEnumerationPidl->mkid.cb == 0)
return;
LPCITEMIDLIST aTempPidl = myEnumerationPidl;
IShellFolder * aTempSF = 0;
SHGetDesktopFolder(&aTempSF);
while(aTempPidl != 0)
{
// the PIDL needs not be destroyed here since ShellFolder will destroy it
LPITEMIDLIST aLocalSinglePidl = UtilPidlFunc::Copy<MemoryWriter_Crt>(aTempPidl, aTempPidl->mkid.cb);
#ifdef SUPPORT_CURFOLDER_AS_ITEM
myItems.push_back( ShellFolderWithPidl(aTempSF, aLocalSinglePidl) );
#else
myItems.push_back( new ShellFolder(aLocalSinglePidl, aTempSF) );
#endif
// Advance the Shell Folder to the next PIDL
IShellFolder * aSF = 0;
HRESULT aRes = aTempSF->BindToObject(aLocalSinglePidl, NULL, IID_IShellFolder, (void **) &aSF);
if ( FAILED(aRes) || aSF == 0)
break;
aTempSF->Release();
aTempSF = aSF;
// Advance the PIDL
aTempPidl = UtilPidlFunc::GetNextItemID(aTempPidl);
}
aTempSF->Release();
}
示例5: SHGetContextMenu
HRESULT CContextMenuHelper::SHGetContextMenu(std::vector<LPCTSTR> files) {
HRESULT hr;
IMalloc *pm = NULL;
IShellFolder *pDesktop = NULL;
IShellFolder *psf = NULL;
LPITEMIDLIST pidl = NULL;
WCHAR fwname[MAX_PATH + 1];
if (SUCCEEDED(hr = SHGetMalloc(&pm))) {
if (SUCCEEDED(hr = SHGetDesktopFolder(&pDesktop))) {
std::vector<LPITEMIDLIST> pidls;
IShellFolder* psfFolder = NULL;
for (UINT i = 0; SUCCEEDED(hr) && i < files.size(); i++) {
LPCTSTR lpszFilePath = files[i];
ULONG cch;
ULONG attrs;
// Convert to Unicode
memset(fwname, L'\0', (MAX_PATH + 1) * sizeof(WCHAR));
MultiByteToWideChar(CP_THREAD_ACP, 0, lpszFilePath, -1, fwname, MAX_PATH);
if (SUCCEEDED(hr = pDesktop->ParseDisplayName(m_hWnd, NULL, fwname, &cch, &pidl, &attrs))) {
LPITEMIDLIST pidlItem = NULL;
if (SUCCEEDED(hr = SHBindToParentEx((LPCITEMIDLIST)pidl, IID_IShellFolder, (void **)&psf, (LPCITEMIDLIST *) &pidlItem, pDesktop, pm))) {
pidls.push_back(CopyPIDL(pidlItem, pm));
pm->Free(pidlItem);
if (psfFolder == NULL) {
// Remember first folder and we wiil show menu for this one
// All other folder will be ignored
psfFolder = psf;
} else {
psf->Release();
}
}
pm->Free(pidl);
}
}
if (SUCCEEDED(hr) && psfFolder != NULL) {
hr = psfFolder->GetUIObjectOf(m_hWnd, pidls.size(), const_cast<LPCITEMIDLIST*>(pidls.begin()), IID_IContextMenu, NULL, (void**)&m_lpcm);
psfFolder->Release();
}
FreeItemIDList(pidls, pm);
pDesktop->Release();
}
pm->Release();
}
return hr;
}
示例6: GetIDListForParent
LPITEMIDLIST ShellFunctions::GetIDListForParent(LPCSTR lpszFileName)
{
int temp=LastCharIndex(lpszFileName,'\\');
LPCWSTR szFolder;
if (temp==-1)
szFolder=alloccopyAtoW(lpszFileName);
else
szFolder=alloccopyAtoW(lpszFileName,temp+1);
LPITEMIDLIST pidl=NULL;
IShellFolder *pDesktop;
if (FAILED(SHGetDesktopFolder(&pDesktop)))
{
delete[] szFolder;
return NULL;
}
if (FAILED(pDesktop->ParseDisplayName(NULL,NULL,(LPOLESTR)szFolder,NULL,&pidl,NULL)))
{
pDesktop->Release();
delete[] szFolder;
return NULL;
}
return pidl;
}
示例7: GetItemIDListFromPath
HRESULT CFShellUtil::GetItemIDListFromPath(LPCTSTR szFullPath, LPITEMIDLIST* ppidl, IShellFolder* pSF)
{
HRESULT hr = E_FAIL;
IShellFolder* pShellFolder = pSF;
if ( pShellFolder == NULL )
{
COM_VERIFY(SHGetDesktopFolder( &pShellFolder ));
if ( !pShellFolder )
{
return hr;
}
}
ULONG chEaten = 0;
DWORD dwAttributes = SFGAO_COMPRESSED;
OLECHAR olePath[MAX_PATH] = { '\0' };
#ifdef UNICODE
StringCchCopy( olePath, MAX_PATH, szFullPath );
#else
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szFileName, -1, olePath, MAX_PATH );
#endif
//LPWSTR pszNPath = (LPWSTR)conv.TCHAR_TO_UTF16(szFullPath);
COM_VERIFY(pShellFolder->ParseDisplayName(NULL, NULL, olePath, &chEaten, ppidl, &dwAttributes));
if ( NULL == pSF )
{
pShellFolder->Release();
pShellFolder = NULL;
}
return hr;
}
示例8: GetItemIdName
HRESULT CFShellUtil::GetItemIdName( LPCITEMIDLIST pItemIdList, LPTSTR pFriendlyName, UINT cchBuf,
DWORD dwFlags, IShellFolder* pSF )
{
HRESULT hr = S_OK;
STRRET strRet = {0};
IShellFolder* pShellFolder = pSF;
if ( pShellFolder == NULL )
{
COM_VERIFY(SHGetDesktopFolder( &pShellFolder ));
if ( !pShellFolder )
{
return hr;
}
}
COM_VERIFY(pShellFolder->GetDisplayNameOf( pItemIdList, dwFlags, &strRet));
if (SUCCEEDED(hr))
{
COM_VERIFY(StrRetToBuf( &strRet, pItemIdList, pFriendlyName, cchBuf));
}
if ( NULL == pSF )
{
pShellFolder->Release();
pShellFolder = NULL;
}
return hr;
}
示例9: GetDisplayName
HRESULT GetDisplayName(LPCITEMIDLIST pidlDirectory,TCHAR *szDisplayName,UINT cchMax,DWORD uFlags)
{
if(pidlDirectory == NULL ||
szDisplayName == NULL)
{
return E_FAIL;
}
IShellFolder *pShellFolder = NULL;
LPITEMIDLIST pidlRelative = NULL;
STRRET str;
HRESULT hr;
hr = SHBindToParent(pidlDirectory, IID_PPV_ARGS(&pShellFolder),
(LPCITEMIDLIST *)&pidlRelative);
if(SUCCEEDED(hr))
{
hr = pShellFolder->GetDisplayNameOf(pidlRelative,uFlags,&str);
if(SUCCEEDED(hr))
{
hr = StrRetToBuf(&str,pidlDirectory,szDisplayName,cchMax);
}
pShellFolder->Release();
}
return hr;
}
示例10: Properties
void CRecBinViewer::Properties (CSelRowArray &ar)
{
CShellContextMenu scm;
IShellFolder*psfRecycle = NULL;
IShellFolder* psfDesktop = NULL;
SHGetDesktopFolder (&psfDesktop);
LPITEMIDLIST pidl = NULL;
SHGetSpecialFolderLocation (NULL, CSIDL_BITBUCKET, &pidl);
psfDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (LPVOID *)&psfRecycle);
LPITEMIDLIST *pidlArray = (LPITEMIDLIST *) malloc (ar.size () * sizeof (LPITEMIDLIST));
for (int i = 0 ; i < static_cast<int>(ar.size()) ; i++)
pidlArray[i] = m_List[ar[i].m_nRow-1].m_PIDL;
scm.SetObjects (psfRecycle, pidlArray, ar.size ());
free (pidlArray);
psfDesktop->Release ();
scm.InvokeCommand (_T("properties"));
if (psfRecycle)
psfRecycle->Release ();
}
示例11: ContextMenu
void CRecBinViewer::ContextMenu (CView* pView, CSelRowArray &ar, CPoint &pt)
{
CShellContextMenu scm;
IShellFolder*psfRecycle = NULL;
IShellFolder* psfDesktop = NULL;
SHGetDesktopFolder (&psfDesktop);
LPITEMIDLIST pidl = NULL;
SHGetSpecialFolderLocation (NULL, CSIDL_BITBUCKET, &pidl);
psfDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (LPVOID *)&psfRecycle);
LPITEMIDLIST *pidlArray = (LPITEMIDLIST *) malloc (ar.size () * sizeof (LPITEMIDLIST));
for (unsigned int i = 0 ; i < ar.size () ; i++)
pidlArray[i] = m_List[ar[i].m_nRow-1].m_PIDL;
scm.SetObjects (psfRecycle, pidlArray, ar.size ());
free (pidlArray);
psfDesktop->Release ();
scm.ShowContextMenu (pView, pt);
if (psfRecycle)
psfRecycle->Release ();
}
示例12: GetIdlFromParsingName
HRESULT GetIdlFromParsingName(const TCHAR *szParsingName,LPITEMIDLIST *pidl)
{
if(szParsingName == NULL ||
pidl == NULL)
{
return E_FAIL;
}
IShellFolder *pDesktopFolder = NULL;
HRESULT hr;
hr = SHGetDesktopFolder(&pDesktopFolder);
if(SUCCEEDED(hr))
{
/* For some reason, ParseDisplayName
takes a pointer to a non-constant
string, so copy the incoming string. */
TCHAR szParsingNameTemp[MAX_PATH];
StringCchCopy(szParsingNameTemp, SIZEOF_ARRAY(szParsingNameTemp), szParsingName);
hr = pDesktopFolder->ParseDisplayName(NULL,NULL,
szParsingNameTemp,NULL,pidl,NULL);
pDesktopFolder->Release();
}
return hr;
}
示例13: GetIconFromItem
//------------------------------------------------------------------------------
// CDevicePropertyPage::GetIconFromItem [STATIC FUNC]
//
// Gets a handle to the icon of the shell item. phIcon needs to be cleaned
// up with DestroyIcon() when done.
//------------------------------------------------------------------------------
HRESULT CDevicePropertyPage::GetIconFromItem(
__in IShellItem* pShellItem,
__in int iImageList,
__out HICON* phIcon
)
{
HRESULT hr = S_OK;
int iIcon = 0;
PITEMID_CHILD pidl = NULL;
IImageList* pImageList = NULL;
IParentAndItem* pParentAndItem = NULL;
IShellFolder* pShellFolder = NULL;
*phIcon = NULL;
hr = pShellItem->QueryInterface( &pParentAndItem );
if( S_OK == hr )
{
hr = pParentAndItem->GetParentAndItem( NULL, &pShellFolder, &pidl );
}
if( S_OK == hr )
{
hr = SHGetImageList(
iImageList,
__uuidof(IImageList),
reinterpret_cast<void**>(&pImageList)
);
}
if( S_OK == hr )
{
iIcon = SHMapPIDLToSystemImageListIndex( pShellFolder, pidl, NULL );
hr = pImageList->GetIcon( iIcon, 0, phIcon );
}
//
// Cleanup
//
if( NULL != pImageList )
{
pImageList->Release();
}
if( NULL != pidl )
{
ILFree( pidl );
}
if( NULL != pShellFolder )
{
pShellFolder->Release();
}
if( NULL != pParentAndItem )
{
pParentAndItem->Release();
}
return hr;
}// CDevicePropertyPage::GetIconFromItem
示例14: HandleRightClickDrop
void CDropHandler::HandleRightClickDrop(void)
{
IShellFolder *pDesktop = NULL;
IShellFolder *pShellFolder = NULL;
IDropTarget *pDrop = NULL;
LPITEMIDLIST pidlDirectory = NULL;
DWORD dwe;
HRESULT hr;
hr = GetIdlFromParsingName(m_szDestDirectory,&pidlDirectory);
if(SUCCEEDED(hr))
{
hr = SHGetDesktopFolder(&pDesktop);
if(SUCCEEDED(hr))
{
hr = pDesktop->BindToObject(pidlDirectory,0,IID_IShellFolder,(void **)&pShellFolder);
if(SUCCEEDED(hr))
{
dwe = *m_pdwEffect;
hr = pShellFolder->CreateViewObject(m_hwndDrop,IID_IDropTarget,(void **)&pDrop);
if(SUCCEEDED(hr))
{
pDrop->DragEnter(m_pDataObject,MK_RBUTTON,m_ptl,&dwe);
dwe = *m_pdwEffect;
pDrop->Drop(m_pDataObject,m_grfKeyState,m_ptl,&dwe);
pDrop->DragLeave();
pDrop->Release();
}
pShellFolder->Release();
}
pDesktop->Release();
}
CoTaskMemFree(pidlDirectory);
}
}
示例15: DetermineItemTotalSizeGroup
/* TODO: These groups have changed as of Windows Vista. */
void CShellBrowser::DetermineItemTotalSizeGroup(int iItemInternal,TCHAR *szGroupHeader,int cchMax) const
{
IShellFolder *pShellFolder = NULL;
LPITEMIDLIST pidlComplete = NULL;
LPITEMIDLIST pidlDirectory = NULL;
LPITEMIDLIST pidlRelative = NULL;
TCHAR *SizeGroups[] = {_T("Unspecified"),_T("Small"),_T("Medium"),_T("Huge"),_T("Gigantic")};
TCHAR szItem[MAX_PATH];
STRRET str;
ULARGE_INTEGER nTotalBytes;
ULARGE_INTEGER nFreeBytes;
BOOL bRoot;
BOOL bRes = FALSE;
ULARGE_INTEGER TotalSizeGroupLimits[6];
int nGroups = 5;
int iSize = 0;
int i;
TotalSizeGroupLimits[0].QuadPart = 0;
TotalSizeGroupLimits[1].QuadPart = 0;
TotalSizeGroupLimits[2].QuadPart = GBYTE;
TotalSizeGroupLimits[3].QuadPart = 20 * TotalSizeGroupLimits[2].QuadPart;
TotalSizeGroupLimits[4].QuadPart = 100 * TotalSizeGroupLimits[2].QuadPart;
GetIdlFromParsingName(m_CurDir,&pidlDirectory);
pidlComplete = ILCombine(pidlDirectory,m_pExtraItemInfo[iItemInternal].pridl);
SHBindToParent(pidlComplete, IID_PPV_ARGS(&pShellFolder), (LPCITEMIDLIST *) &pidlRelative);
pShellFolder->GetDisplayNameOf(pidlRelative,SHGDN_FORPARSING,&str);
StrRetToBuf(&str,pidlRelative,szItem,SIZEOF_ARRAY(szItem));
bRoot = PathIsRoot(szItem);
if(bRoot)
{
bRes = GetDiskFreeSpaceEx(szItem,NULL,&nTotalBytes,&nFreeBytes);
CoTaskMemFree(pidlDirectory);
CoTaskMemFree(pidlComplete);
pShellFolder->Release();
i = nGroups - 1;
while(nTotalBytes.QuadPart < TotalSizeGroupLimits[i].QuadPart && i > 0)
i--;
iSize = i;
}
if(!bRoot || !bRes)
{
iSize = 0;
}
StringCchCopy(szGroupHeader,cchMax,SizeGroups[iSize]);
}