当前位置: 首页>>代码示例>>C++>>正文


C++ IShellFolder类代码示例

本文整理汇总了C++中IShellFolder的典型用法代码示例。如果您正苦于以下问题:C++ IShellFolder类的具体用法?C++ IShellFolder怎么用?C++ IShellFolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IShellFolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
	}
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:28,代码来源:ftlShell.hpp

示例2: 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;
    }
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:31,代码来源:ftlShell.hpp

示例3: SHParseDisplayName

std::wstring OsShell::toolTip(std::wstring itemPath)
{
	ComInitializer comInitializer;

	std::replace(itemPath.begin(), itemPath.end(), '/', '\\');
	std::wstring tipString;
	ITEMIDLIST * id = 0;
	HRESULT result = SHParseDisplayName(itemPath.c_str(), 0, &id, 0, 0);
	if (!SUCCEEDED(result) || !id)
		return tipString;
	CItemIdListReleaser idReleaser (id);

	LPCITEMIDLIST child = 0;
	IShellFolder * ifolder = 0;
	result = SHBindToParent(id, IID_IShellFolder, (void**)&ifolder, &child);
	if (!SUCCEEDED(result) || !child)
		return tipString;

	IQueryInfo* iQueryInfo = 0;
	if (SUCCEEDED(ifolder->GetUIObjectOf(NULL, 1, &child, IID_IQueryInfo, 0, (void**)&iQueryInfo)) && iQueryInfo)
	{
		LPWSTR lpszTip = 0;
		CComInterfaceReleaser releaser (iQueryInfo);
		if (SUCCEEDED(iQueryInfo->GetInfoTip(0, &lpszTip)) && lpszTip)
		{
			tipString = lpszTip;
			CoTaskMemFree(lpszTip);
		}
	}

	std::replace(tipString.begin(), tipString.end(), '\r', '\n');
	return tipString;
}
开发者ID:VioletGiraffe,项目名称:file-commander,代码行数:33,代码来源:cshell.cpp

示例4: 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;
}
开发者ID:hollylee,项目名称:explorerplusplus,代码行数:29,代码来源:ShellHelper.cpp

示例5: SHGetDesktopFolder

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 ();
	
}
开发者ID:avrionov,项目名称:explorerxp,代码行数:27,代码来源:RecBinViewer.cpp

示例6: JNU_ThrowInternalError

/*
 * Class:     sun_awt_shell_Win32ShellFolder2
 * Method:    parseDisplayName0
 * Signature: (JLjava/lang/String;)J
 */
JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_parseDisplayName0
    (JNIEnv* env, jclass cls, jlong jpIShellFolder, jstring jname)
{

    // Get desktop IShellFolder interface
    IShellFolder* pIShellFolder = (IShellFolder*)jpIShellFolder;
    if (pIShellFolder == NULL) {
        JNU_ThrowInternalError(env, "Desktop shell folder missing");
        return 0;
    }
    // Get relative PIDL for name
    LPITEMIDLIST pIDL;
    int nLength = env->GetStringLength(jname);
    const jchar* strPath = env->GetStringChars(jname, NULL);
    JNU_CHECK_EXCEPTION_RETURN(env, 0);
    jchar* wszPath = new jchar[nLength + 1];
    wcsncpy(reinterpret_cast<LPWSTR>(wszPath), reinterpret_cast<LPCWSTR>(strPath), nLength);
    wszPath[nLength] = 0;
    HRESULT res = pIShellFolder->ParseDisplayName(NULL, NULL,
                        reinterpret_cast<LPWSTR>(wszPath), NULL, &pIDL, NULL);
    if (res != S_OK) {
        JNU_ThrowIOException(env, "Could not parse name");
        pIDL = 0;
    }
    delete[] wszPath;
    env->ReleaseStringChars(jname, strPath);
    return (jlong)pIDL;
}
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:33,代码来源:ShellFolder2.cpp

示例7: create_absolute_pidl

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
}
开发者ID:GYGit,项目名称:reactos,代码行数:60,代码来源:entries.cpp

示例8: SHGetDesktopFolder

CString ShellIO::PIDLToString(LPITEMIDLIST pIdl, LPITEMIDLIST pParentIdl, SHGDNF flags)
{
	IShellFolder *desktopFolder;
	IShellFolder2 *shellFolder = NULL;
	STRRET strRet;
	HRESULT hRes;

	hRes = SHGetDesktopFolder(&desktopFolder);
	if(FAILED(hRes))
	{
		return L"";
	}

	if(pParentIdl)
	{
		desktopFolder->BindToObject((PCUIDLIST_RELATIVE)pParentIdl, NULL, IID_IShellFolder, (void**)&shellFolder);
	}

	if(shellFolder == NULL)
	{
		shellFolder = (IShellFolder2*)desktopFolder;
	}

	hRes = shellFolder->GetDisplayNameOf((PCUITEMID_CHILD)pIdl, flags, &strRet);
	if(FAILED(hRes))
	{
		return L"";
	}
	
	return strRet.pOleStr;
}
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:31,代码来源:shellio.cpp

示例9: return

 /*
  * Class:     sun_awt_shell_Win32ShellFolder
  * Method:    getIcon
  * Signature: (JJZ)J
  */
 JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder_getIcon__JJZ
 (JNIEnv* env, jobject folder, jlong parentIShellFolder, jlong relativePIDL,
  jboolean getLargeIcon)
 {
     IShellFolder* pParent = (IShellFolder*)parentIShellFolder;
     if (pParent == NULL) {
         return 0;
     }
     LPITEMIDLIST pidl = (LPITEMIDLIST)relativePIDL;
     if (pidl == NULL) {
         return 0;
     }
     IExtractIcon* pIcon;
     if (pParent->GetUIObjectOf(NULL, 1, const_cast<LPCITEMIDLIST*>(&pidl),
                                IID_IExtractIcon, NULL, (void**)&pIcon) != S_OK) {
         return 0;
     }
     CHAR szBuf[MAX_PATH];
     INT index;
     UINT flags;
     if (pIcon->GetIconLocation(
                 GIL_FORSHELL, szBuf, MAX_PATH, &index, &flags)
             != S_OK) {
         pIcon->Release();
         return 0;
     }
     HICON hIcon;
     HICON hIconLarge;
     if (pIcon->Extract(szBuf, index, &hIconLarge, &hIcon, (16 << 16) + 32) != S_OK) {
         pIcon->Release();
         return 0;
     }
     return (jlong)(getLargeIcon ? hIconLarge : hIcon);
 }
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:39,代码来源:ShellFolder.cpp

示例10: 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;
}
开发者ID:hollylee,项目名称:explorerplusplus,代码行数:30,代码来源:ShellHelper.cpp

示例11: 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;
}
开发者ID:quachdnguyen,项目名称:locate-src,代码行数:25,代码来源:Shell.cpp

示例12: 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
开发者ID:Ippei-Murofushi,项目名称:WindowsSDK7-Samples,代码行数:65,代码来源:CDevicePropertyPage.cpp

示例13: GetExplorerWindows

void GetExplorerWindows(std::vector<PairHwndPath>& windows, BOOL needPaths) {
    IShellWindows *psw;
    if(SUCCEEDED(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows, (void**)&psw))) {
        VARIANT v;
        V_VT(&v) = VT_I4;
        IDispatch* pdisp;
        for(V_I4(&v) = 0; psw->Item(v, &pdisp) == S_OK; V_I4(&v)++) {
            IWebBrowserApp *pwba;
            if(SUCCEEDED(pdisp->QueryInterface(IID_IWebBrowserApp, (void**)&pwba))) {
                PairHwndPath pair;
                if(SUCCEEDED(pwba->get_HWND((LONG_PTR*)&pair.hwnd))) {
                    IServiceProvider *psp;
                    if(needPaths && SUCCEEDED(pwba->QueryInterface(IID_IServiceProvider, (void**)&psp))) {
                        IShellBrowser *psb;
                        if(SUCCEEDED(psp->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, (void**)&psb))) {
                            IShellView *psv;
                            if(SUCCEEDED(psb->QueryActiveShellView(&psv))) {
                                IFolderView *pfv;
                                if(SUCCEEDED(psv->QueryInterface(IID_IFolderView, (void**)&pfv))) {
                                    IPersistFolder2 *ppf2;
                                    if(SUCCEEDED(pfv->GetFolder(IID_IPersistFolder2, (void**)&ppf2))) {
                                        LPITEMIDLIST pidlFolder;
                                        if(SUCCEEDED(ppf2->GetCurFolder(&pidlFolder))) {
                                            if(!SHGetPathFromIDList(pidlFolder, pair.path)) {
                                                IShellFolder* psf;
                                                LPCITEMIDLIST pidlLast;
                                                if(SUCCEEDED(SHBindToParent(pidlFolder, IID_IShellFolder, (void**)&psf, &pidlLast))) {
                                                    STRRET strret;
                                                    if(SUCCEEDED(psf->GetDisplayNameOf(pidlLast, 0x8000, &strret))) {
                                                        StrRetToBuf(&strret, pidlLast, pair.path, MAX_PATH);
                                                    }
                                                    else {
                                                        pair.path[0] = 0;
                                                    }
                                                    psf->Release();
                                                }
                                            }
                                            CoTaskMemFree(pidlFolder);
                                        }
                                        ppf2->Release();
                                    }
                                    pfv->Release();
                                }
                                psv->Release();
                            }
                            psb->Release();
                        }
                        psp->Release();
                    }
                    windows.push_back(pair);
                }
                pwba->Release();
            }
            pdisp->Release();
        }
        psw->Release();
    }
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:58,代码来源:CustomAction.cpp

示例14: 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]);
}
开发者ID:hollylee,项目名称:explorerplusplus,代码行数:59,代码来源:GroupManager.cpp

示例15: _SortFunc

 // NOTE: Sorting added by Anatoly Ivasyuk.
 static int CALLBACK _SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
 {
     IShellFolder* piSF = reinterpret_cast<IShellFolder*>(lParamSort);
     PSHELLITEMINFO pItem1 = reinterpret_cast<PSHELLITEMINFO>(lParam1);
     PSHELLITEMINFO pItem2 = reinterpret_cast<PSHELLITEMINFO>(lParam2);
     HRESULT Hr = piSF->CompareIDs(0, pItem1->pidlNode, pItem2->pidlNode);
     if( SUCCEEDED(Hr) ) return (SHORT) (Hr & SHCIDS_COLUMNMASK);
     return 0;
 }
开发者ID:Beifeng,项目名称:qui,代码行数:10,代码来源:behavior_shellctrl.cpp


注:本文中的IShellFolder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。