本文整理汇总了C++中IShellFolder::BindToObject方法的典型用法代码示例。如果您正苦于以下问题:C++ IShellFolder::BindToObject方法的具体用法?C++ IShellFolder::BindToObject怎么用?C++ IShellFolder::BindToObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShellFolder
的用法示例。
在下文中一共展示了IShellFolder::BindToObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 ();
}
示例2: 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 ();
}
示例3:
/*
* Class: sun_awt_shell_Win32ShellFolder2
* Method: initSpecial
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolder2_initSpecial
(JNIEnv* env, jobject folder, jlong desktopIShellFolder, jint folderType)
{
// Get desktop IShellFolder interface
IShellFolder* pDesktop = (IShellFolder*)desktopIShellFolder;
if (pDesktop == NULL) {
JNU_ThrowInternalError(env, "Desktop shell folder missing");
return;
}
// Get special folder relative PIDL
LPITEMIDLIST relPIDL;
HRESULT res = fn_SHGetSpecialFolderLocation(NULL, folderType,
&relPIDL);
if (res != S_OK) {
JNU_ThrowIOException(env, "Could not get shell folder ID list");
return;
}
// Set field ID for relative PIDL
env->CallVoidMethod(folder, MID_relativePIDL, (jlong)relPIDL);
// Get special folder IShellFolder interface
IShellFolder* pFolder;
res = pDesktop->BindToObject(relPIDL, NULL, IID_IShellFolder,
(void**)&pFolder);
if (res != S_OK) {
JNU_ThrowInternalError(env,
"Could not bind shell folder to interface");
return;
}
// Set field ID for pIShellFolder
env->CallVoidMethod(folder, MID_pIShellFolder, (jlong)pFolder);
}
示例4: PIDLToString
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;
}
示例5: 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();
}
示例6: 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);
}
}
示例7: return
/*
* Class: sun_awt_shell_Win32ShellFolder2
* Method: bindToObject
* Signature: (JJ)J
*/
JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_bindToObject
(JNIEnv* env, jclass cls, jlong parentIShellFolder, jlong relativePIDL)
{
IShellFolder* pParent = (IShellFolder*)parentIShellFolder;
if (pParent == NULL) {
return 0;
}
LPITEMIDLIST pidl = (LPITEMIDLIST)relativePIDL;
if (pidl == NULL) {
return 0;
}
IShellFolder* pFolder;
HRESULT hr = pParent->BindToObject(pidl, NULL, IID_IShellFolder, (void**)&pFolder);
if (SUCCEEDED (hr)) {
return (jlong)pFolder;
}
return 0;
}
示例8: GetAllFavorites
PFAVORITELIST CFavoriteEngine::GetAllFavorites(){
if(FAILED(CoInitialize(NULL)))
return NULL;
HRESULT hRet = ::SHGetMalloc(&m_pMalloc);
if(FAILED(hRet)){
m_pMalloc->Release();
return NULL;
}
LPITEMIDLIST pidl;
hRet = ::SHGetSpecialFolderLocation( NULL, CSIDL_FAVORITES, &pidl);
if(FAILED(hRet)){
m_pMalloc->Release();
return NULL;
}
IShellFolder *pShellFolder = NULL;
hRet = ::SHGetDesktopFolder (&pShellFolder);
if (FAILED (hRet)){
m_pMalloc->Free (pidl);
m_pMalloc->Release ();
return NULL;
}
IShellFolder *pFavFolder = NULL;
hRet = pShellFolder->BindToObject (pidl, NULL, IID_IShellFolder, reinterpret_cast<void **>(&pFavFolder));
long nItems = 0;
IEnumIDList* pItems = NULL;
hRet = pFavFolder->EnumObjects(NULL, SHCONTF_FOLDERS|SHCONTF_NONFOLDERS, &pItems);
if(m_pFavoListRoot){
CleanUp();
}
m_pFavoListRoot = new FAVORITELIST;
ZeroMemory(m_pFavoListRoot, sizeof(FAVORITELIST));
PFAVORITELIST pFavoListCur = GetFavorite( pFavFolder, m_pFavoListRoot, pItems);
if (NULL != pItems){
pItems->Release();
}
m_pMalloc->Free(pidl);
m_pMalloc->Release();
return m_pFavoListRoot;
}
示例9: SHBindToParentEx
// this is workaround function for the Shell API Function SHBindToParent
// SHBindToParent is not available under Win95/98
HRESULT CShellContextMenu::SHBindToParentEx (LPCITEMIDLIST pidl, REFIID riid, VOID **ppv, LPCITEMIDLIST *ppidlLast)
{
HRESULT hr = 0;
if (!pidl || !ppv)
return E_POINTER;
int nCount = GetPIDLCount (pidl);
if (nCount == 0) // desktop pidl of invalid pidl
return E_POINTER;
IShellFolder * psfDesktop = NULL;
SHGetDesktopFolder (&psfDesktop);
if (nCount == 1) // desktop pidl
{
if ((hr = psfDesktop->QueryInterface(riid, ppv)) == S_OK)
{
if (ppidlLast)
*ppidlLast = CopyPIDL (pidl);
}
psfDesktop->Release ();
return hr;
}
LPBYTE pRel = GetPIDLPos (pidl, nCount - 1);
LPITEMIDLIST pidlParent = NULL;
pidlParent = CopyPIDL (pidl, pRel - (LPBYTE) pidl);
IShellFolder * psfFolder = NULL;
if ((hr = psfDesktop->BindToObject (pidlParent, NULL, __uuidof (psfFolder), (void **) &psfFolder)) != S_OK)
{
free (pidlParent);
psfDesktop->Release ();
return hr;
}
if ((hr = psfFolder->QueryInterface (riid, ppv)) == S_OK)
{
if (ppidlLast)
*ppidlLast = CopyPIDL ((LPCITEMIDLIST) pRel);
}
free (pidlParent);
psfFolder->Release ();
psfDesktop->Release ();
return hr;
}
示例10: return
/*
* Class: sun_awt_shell_Win32ShellFolder
* Method: bindToObject
* Signature: (JJ)J
*/
JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder_bindToObject
(JNIEnv* env, jobject folder, jlong parentIShellFolder, jlong relativePIDL)
{
IShellFolder* pParent = (IShellFolder*)parentIShellFolder;
if (pParent == NULL) {
return 0;
}
LPITEMIDLIST pidl = (LPITEMIDLIST)relativePIDL;
if (pidl == NULL) {
return 0;
}
IShellFolder* pFolder;
if (pParent->BindToObject(pidl, NULL, IID_IShellFolder, (void**)&pFolder)
!= S_OK)
{
return 0;
}
return (jlong)pFolder;
}
示例11: SHBindToParentEx
// this is workaround function for the Shell API Function SHBindToParent
// SHBindToParent is not available under Win95/98
HRESULT CContextMenuHelper::SHBindToParentEx(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast, IShellFolder *psfDesktop, IMalloc *pm) {
HRESULT hr = 0;
if (pidl == NULL || ppv == NULL) {
return E_POINTER;
}
IShellFolder *psfFolder = NULL;
if (SUCCEEDED(hr == psfDesktop->QueryInterface(riid, (LPVOID*)&psfFolder))) {
IShellFolder *psfParent = NULL;
// For each pidl component, bind to folder
LPITEMIDLIST pidlNext, pidlLast;
pidlNext = NEXTPIDL(pidl);
pidlLast = (LPITEMIDLIST)pidl;
while (pidlNext->mkid.cb != 0) {
UINT uSave = pidlNext->mkid.cb; //stop the chain temporarily
pidlNext->mkid.cb = 0; //so we can bind to the next folder 1 deeper
if (!SUCCEEDED(hr = psfFolder->BindToObject(pidlLast, NULL, riid, (LPVOID*)&psfParent))) {
return hr;
}
pidlNext->mkid.cb = uSave; //restore the chain
psfFolder->Release(); //and set up to work with the next-level folder
psfFolder = psfParent;
pidlLast = pidlNext;
pidlNext = NEXTPIDL(pidlNext); //advance to next pidl
}
if (ppidlLast != NULL) {
*ppidlLast = CopyPIDL((LPCITEMIDLIST)pidlLast, pm);
}
*ppv = psfFolder;
}
return hr;
}
示例12: sh_get_folder_interface
IShellFolder* sh_get_folder_interface(LPCITEMIDLIST pIDFolder)
{
IShellFolder* pShellFolder = NULL;
IShellFolder* pThisFolder = NULL;
HRESULT hr;
hr = SHGetDesktopFolder(&pShellFolder);
if (NOERROR != hr)
return NULL;
if (NextID(pIDFolder) == pIDFolder)
return pShellFolder;
hr = pShellFolder->BindToObject(
pIDFolder, NULL, IID_IShellFolder, (LPVOID*)&pThisFolder);
pShellFolder->Release();
if (NOERROR != hr)
return NULL;
return pThisFolder;
}
示例13: ExtractThumbnailImageInternal
void CDisplayWindow::ExtractThumbnailImageInternal(ThumbnailEntry_t *pte)
{
IExtractImage *pExtractImage = NULL;
IShellFolder *pShellDesktop = NULL;
IShellFolder *pShellFolder = NULL;
LPITEMIDLIST pidlParent = NULL;
LPITEMIDLIST pidlFull = NULL;
LPITEMIDLIST pridl = NULL;
HBITMAP hBitmap;
BITMAP bm;
RECT rc;
SIZE size;
TCHAR szImage[MAX_PATH];
DWORD dwPriority;
DWORD dwFlags;
HRESULT hr;
m_bThumbnailExtracted = TRUE;
m_bThumbnailExtractionFailed = TRUE;
hr = GetIdlFromParsingName(m_ImageFile,&pidlFull);
if(SUCCEEDED(hr))
{
pidlParent = ILClone(pidlFull);
ILRemoveLastID(pidlParent);
pridl = ILClone(ILFindLastID(pidlFull));
hr = SHGetDesktopFolder(&pShellDesktop);
if(SUCCEEDED(hr))
{
hr = pShellDesktop->BindToObject(pidlParent,NULL,IID_IShellFolder,(void **)&pShellFolder);
if(SUCCEEDED(hr))
{
hr = pShellFolder->GetUIObjectOf(NULL,1,(LPCITEMIDLIST *)&pridl,
IID_IExtractImage,NULL,(void **)&pExtractImage);
if(SUCCEEDED(hr))
{
GetClientRect(m_hDisplayWindow,&rc);
/* First, query the thumbnail so that its actual aspect
ratio can be calculated. */
dwFlags = IEIFLAG_OFFLINE|IEIFLAG_QUALITY|IEIFLAG_ORIGSIZE;
size.cx = GetRectHeight(&rc) - THUMB_HEIGHT_DELTA;
size.cy = GetRectHeight(&rc) - THUMB_HEIGHT_DELTA;
hr = pExtractImage->GetLocation(szImage,MAX_PATH,
&dwPriority,&size,32,&dwFlags);
if(SUCCEEDED(hr))
{
hr = pExtractImage->Extract(&hBitmap);
if(SUCCEEDED(hr))
{
/* Get bitmap information (including height and width). */
GetObject(hBitmap,sizeof(BITMAP),&bm);
/* Delete the original bitmap. */
DeleteObject(hBitmap);
/* ...now query the thumbnail again, this time adjusting
the width of the suggested area based on the actual aspect
ratio. */
dwFlags = IEIFLAG_OFFLINE|IEIFLAG_QUALITY|IEIFLAG_ASPECT|IEIFLAG_ORIGSIZE;
size.cy = GetRectHeight(&rc) - THUMB_HEIGHT_DELTA;
size.cx = (LONG)((double)size.cy * ((double)bm.bmWidth / (double)bm.bmHeight));
m_iImageWidth = size.cx;
m_iImageHeight = size.cy;
pExtractImage->GetLocation(szImage,MAX_PATH,
&dwPriority,&size,32,&dwFlags);
hr = pExtractImage->Extract(&m_hbmThumbnail);
if(SUCCEEDED(hr))
{
/* Check first if we've been cancelled. This might happen,
for example, if another file is selected while the current
thumbnail is been found. */
EnterCriticalSection(&m_csDWThumbnails);
if(!pte->bCancelled)
{
m_bThumbnailExtractionFailed = FALSE;
InvalidateRect(m_hDisplayWindow,NULL,FALSE);
}
LeaveCriticalSection(&m_csDWThumbnails);
}
else
{
m_bThumbnailExtractionFailed = TRUE;
m_hbmThumbnail = NULL;
}
}
}
//.........这里部分代码省略.........
示例14: GetDrives
void GetDrives (CDriveArray &array)
{
array.clear ();
IShellFolder *psfDesktop;
SHGetDesktopFolder(&psfDesktop);
if(psfDesktop == NULL)
return;
LPITEMIDLIST pidlMyComputer;
SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlMyComputer);
if(pidlMyComputer == NULL)
{
psfDesktop->Release();
return;
}
IShellFolder *psfMyComputer;
psfDesktop->BindToObject(pidlMyComputer, NULL, IID_IShellFolder, (LPVOID*)&psfMyComputer);
if(psfMyComputer)
{
IEnumIDList* pEnum;
if(SUCCEEDED(psfMyComputer->EnumObjects(NULL, SHCONTF_FOLDERS|SHCONTF_INCLUDEHIDDEN, &pEnum)))
{
ITEMIDLIST* pidl;
DWORD dwFetched = 1;
TCHAR path[MAX_PATH];
while(SUCCEEDED(pEnum->Next(1, &pidl, &dwFetched)) && dwFetched)
{
SHFILEINFO sfi;
//LPITEMIDLIST pidl_full = Pidl_Concatenate (pidlMyComputer, pidl);
LPITEMIDLIST pidl_full = ILCombine (pidlMyComputer, pidl);
SHGetPathFromIDList (pidl_full, path);
UINT nType = GetDriveType( path);
// if( DRIVE_REMOVABLE < nType && nType <= DRIVE_RAMDISK )
if( nType != DRIVE_UNKNOWN && nType != DRIVE_NO_ROOT_DIR )
if(SHGetFileInfo((LPCTSTR)pidl_full, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_LINKOVERLAY))
{
CDriveInfo info;
info.m_Name = sfi.szDisplayName;
info.m_Path = path;
info.m_Type = sfi.szTypeName;
info.m_nImage = sfi.iIcon;
info.m_nType = nType;
DWORD SectorsPerCluster; // sectors per cluster
DWORD BytesPerSector; // bytes per sector
DWORD NumberOfFreeClusters; // free clusters
DWORD TotalNumberOfClusters; // total clusters
// TRACE (L"%s %s\n", sfi.szDisplayName, path);
if (nType != DRIVE_REMOVABLE )
if (GetDiskFreeSpace (path, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters))
{
DWORD BytesPerCluster = BytesPerSector * SectorsPerCluster;
info.m_FreeSpace = UInt32x32To64(NumberOfFreeClusters, BytesPerCluster);
info.m_TotalSize= UInt32x32To64(TotalNumberOfClusters, BytesPerCluster);
}
array.push_back (info);
}
}
pEnum->Release ();
}
psfMyComputer->Release();
}
CoTaskMemFree(pidlMyComputer);
psfDesktop->Release();
}
示例15: PrintImage
BOOL CImageUtility::PrintImage(wchar_t* path, wchar_t* file_name )
{
IShellFolder* pDesktop = NULL;
HRESULT hr = ::SHGetDesktopFolder( &pDesktop );
if( !SUCCEEDED( hr ) )
return FALSE;
LPITEMIDLIST pidl = NULL;
hr = pDesktop->ParseDisplayName(NULL, NULL, path, NULL, &pidl, NULL);
if( !SUCCEEDED( hr ) )
{
pDesktop->Release();
return FALSE;
}
IShellFolder* pPath = NULL;
hr = pDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (void**)(&pPath) );
if( !SUCCEEDED( hr ) )
{
pDesktop->Release();
CoTaskMemFree( pidl );
return FALSE;
}
LPITEMIDLIST pidl2 = NULL;
hr = pPath->ParseDisplayName(NULL, NULL, file_name, NULL, &pidl2, NULL);
if( !SUCCEEDED( hr ) )
{
pDesktop->Release();
CoTaskMemFree( pidl );
pPath->Release();
return FALSE;
}
IContextMenu* contextMenu_ptr = NULL;
hr = pPath->GetUIObjectOf( GetActiveWindow(), 1, (LPCITEMIDLIST*)(&pidl2), IID_IContextMenu, NULL,(void**)(&contextMenu_ptr) );
if( !SUCCEEDED( hr ) )
{
pDesktop->Release();
CoTaskMemFree( pidl );
pPath->Release();
CoTaskMemFree( pidl2 );
return FALSE;
}
HMENU hMenu = CreatePopupMenu();
if( hMenu == NULL )
{
pDesktop->Release();
CoTaskMemFree( pidl );
pPath->Release();
CoTaskMemFree( pidl2 );
contextMenu_ptr->Release();
return FALSE;
}
contextMenu_ptr->QueryContextMenu( hMenu, 0, 1, 0x7FFF, CMF_NORMAL );
CMINVOKECOMMANDINFO cmdInfo;
::memset( &cmdInfo, 0, sizeof(CMINVOKECOMMANDINFO) );
cmdInfo.cbSize = sizeof(CMINVOKECOMMANDINFO);
cmdInfo.lpVerb = "print";//"properties";"Print"
cmdInfo.nShow = SW_SHOW;
cmdInfo.hwnd = GetActiveWindow();
hr = contextMenu_ptr->InvokeCommand( &cmdInfo );
pDesktop->Release();
CoTaskMemFree( pidl );
pPath->Release();
CoTaskMemFree( pidl2 );
contextMenu_ptr->Release();
DestroyMenu( hMenu );
if( SUCCEEDED( hr ) )
return TRUE;
else
return FALSE;
}