本文整理汇总了C++中IEnumIDList::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IEnumIDList::Release方法的具体用法?C++ IEnumIDList::Release怎么用?C++ IEnumIDList::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumIDList
的用法示例。
在下文中一共展示了IEnumIDList::Release方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*
* Class: sun_awt_shell_Win32ShellFolder2
* Method: releaseEnumObjects
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolder2_releaseEnumObjects
(JNIEnv* env, jobject folder, jlong pEnumObjects)
{
IEnumIDList* pEnum = (IEnumIDList*)pEnumObjects;
if (pEnum == NULL) {
return;
}
pEnum->Release();
}
示例2: 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;
}
示例3: 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();
}
示例4: enumObjects
//.........这里部分代码省略.........
(pItemInfo->displayName[displayNameSize-3] == 'V') &&
(pItemInfo->displayName[displayNameSize-2] == 'S') &&
( (pItemInfo->displayName[displayNameSize-1] == '\\') || (pItemInfo->displayName[displayNameSize-1] == '/') );
}*/
// Continue ?
if (!folder || !cvs)
{
// Filter
uint filter;
uint filterCount = _ExclusiveExtFilter.size ();
// Get the extension
uint pos = pItemInfo->displayName.rfind ('.');
const char *extName = NULL;
if (pos != string::npos)
extName = pItemInfo->displayName.c_str ()+pos;
if (!folder)
for (filter=0; filter<filterCount; filter++)
{
if (extName)
{
if (stricmp (extName, _ExclusiveExtFilter[filter].c_str ()) == 0)
break;
}
}
// All exclusive filters ok ?
if (folder || (filter < filterCount) || (filterCount == 0))
{
filterCount = _NegativeExtFilter.size ();
if (!folder)
for (filter=0; filter<filterCount; filter++)
{
if (extName)
{
if (stricmp (extName, _NegativeExtFilter[filter].c_str ()) == 0)
break;
}
}
// All negative filters ok ?
if (folder || (filter == filterCount))
{
tvItem.cChildren = (pItemInfo->dwFlags & SFGAO_FOLDER) && ((pItemInfo->dwFlags & SFGAO_LINK) ==0);
if(pItemInfo->dwFlags & SFGAO_SHARE)
{
tvItem.mask |= TVIF_STATE;
tvItem.stateMask |= TVIS_OVERLAYMASK;
tvItem.state |= INDEXTOOVERLAYMASK(1);
}
tvInsert.item = tvItem;
tvInsert.hInsertAfter = TVI_LAST;
tvInsert.hParent = hParentItem;
_TreeCtrl.InsertItem(&tvInsert);
dwFetched = 0;
inserted = true;
}
}
}
}
if (!inserted)
{
/*tvInsert.item.mask = LVIF_IMAGE;
tvInsert.item.stateMask = 0;
tvInsert.item.state = 0;
tvInsert.item.mask = 0;
tvInsert.item.pszText = 0;
tvInsert.item.iImage = tvInsert.item.iSelectedImage = 10;
tvInsert.item.lParam = NULL;
tvInsert.item.cChildren = 0;
tvInsert.hInsertAfter = TVI_LAST;
tvInsert.hParent = hParentItem;
_TreeCtrl.InsertItem(&tvInsert);*/
/*HTREEITEM hItem = _TreeCtrl.InsertItem ("", hParentItem );
_TreeCtrl.SetItemImage( hItem, 0xffffffff, 0xffffffff );*/
/*memset (&tvItem, 0, sizeof (TVITEM));
tvItem.hItem = hParentItem;
nlverify (_TreeCtrl.GetItem( &tvItem ));
tvItem.cChildren = 0;
nlverify (_TreeCtrl.SetItem( &tvItem ));*/
}
// Sort the list
if (_ArrangeMode != None)
{
TVSORTCB tvSort;
tvSort.hParent = hParentItem;
tvSort.lpfnCompare = CompareFunc;
tvSort.lParam = (LPARAM)this;
_TreeCtrl.SortChildrenCB( &tvSort );
}
pEnum->Release();
return true;
}
return false;
}
示例5: FindPaths
bool CDeskBand::FindPaths()
{
m_currentDirectory.clear();
m_selectedItems.clear();
m_bFilesSelected = false;
m_bFolderSelected = false;
if (m_pSite == NULL)
return false;
IServiceProvider * pServiceProvider;
if (SUCCEEDED(m_pSite->QueryInterface(IID_IServiceProvider, (LPVOID*)&pServiceProvider)))
{
IShellBrowser * pShellBrowser;
if (SUCCEEDED(pServiceProvider->QueryService(SID_SShellBrowser, IID_IShellBrowser, (LPVOID*)&pShellBrowser)))
{
IShellView * pShellView;
if (SUCCEEDED(pShellBrowser->QueryActiveShellView(&pShellView)))
{
IFolderView * pFolderView;
if (SUCCEEDED(pShellView->QueryInterface(IID_IFolderView, (LPVOID*)&pFolderView)))
{
// hooray! we got the IFolderView interface!
// that means the explorer is active and well :)
// but we also need the IShellFolder interface because
// we need its GetCurFolder() method
IPersistFolder2 * pPersistFolder;
if (SUCCEEDED(pFolderView->GetFolder(IID_IPersistFolder2, (LPVOID*)&pPersistFolder)))
{
LPITEMIDLIST folderpidl;
if (SUCCEEDED(pPersistFolder->GetCurFolder(&folderpidl)))
{
// we have the current folder
TCHAR buf[MAX_PATH] = {0};
// find the path of the folder
if (SHGetPathFromIDList(folderpidl, buf))
{
m_currentDirectory = buf;
}
// if m_currentDirectory is empty here, that means
// the current directory is a virtual path
IShellFolder * pShellFolder;
if (SUCCEEDED(pPersistFolder->QueryInterface(IID_IShellFolder, (LPVOID*)&pShellFolder)))
{
// if there was a new folder created but not found to set into editing mode,
// we try here to do that
if (!m_newfolderPidls.empty())
{
int nCount2 = 0;
IShellFolder * pShellFolder;
if (SUCCEEDED(pPersistFolder->QueryInterface(IID_IShellFolder, (LPVOID*)&pShellFolder)))
{
if (SUCCEEDED(pFolderView->ItemCount(SVGIO_ALLVIEW, &nCount2)))
{
for (int i=0; i<nCount2; ++i)
{
LPITEMIDLIST pidl;
pFolderView->Item(i, &pidl);
bool bFound = false;
for (std::vector<LPITEMIDLIST>::iterator it = m_newfolderPidls.begin(); it != m_newfolderPidls.end(); ++it)
{
HRESULT hr = pShellFolder->CompareIDs(0, pidl, *it);
if (HRESULT_CODE(hr) == 0)
{
// this item was there before, so it's not the new folder
CoTaskMemFree(*it);
m_newfolderPidls.erase(it);
bFound = true;
break;
}
}
if (!bFound)
{
pShellView->SelectItem(pidl, SVSI_EDIT);
}
CoTaskMemFree(pidl);
}
}
if ((nCount2)||(m_newfolderTimeoutCounter-- <= 0))
{
m_newfolderTimeoutCounter = 0;
for (std::vector<LPITEMIDLIST>::iterator it = m_newfolderPidls.begin(); it != m_newfolderPidls.end(); ++it)
{
CoTaskMemFree(*it);
}
m_newfolderPidls.clear();
}
pShellFolder->Release();
}
}
// find all selected items
IEnumIDList * pEnum;
if (SUCCEEDED(pFolderView->Items(SVGIO_SELECTION, IID_IEnumIDList, (LPVOID*)&pEnum)))
{
LPITEMIDLIST pidl;
WCHAR buf[MAX_PATH] = {0};
ULONG fetched = 0;
ULONG attribs = 0;
//.........这里部分代码省略.........
示例6: Rename
//.........这里部分代码省略.........
{
pidl = NULL;
if (SUCCEEDED(pEnum->Next(1, &pidl, &fetched)))
{
if (fetched)
{
// the pidl we get here is relative!
attribs = SFGAO_FILESYSTEM|SFGAO_FOLDER;
if (SUCCEEDED(pShellFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidl, &attribs)))
{
if (attribs & SFGAO_FILESYSTEM)
{
// create an absolute pidl with the pidl we got above
LPITEMIDLIST abspidl = CPidl::Append(folderpidl, pidl);
if (abspidl)
{
if (SHGetPathFromIDList(abspidl, buf))
{
std::wstring p = buf;
size_t pos = p.find_last_of('\\');
if (pos != std::wstring::npos)
{
m_filelist.insert(p.substr(pos+1));
}
}
CoTaskMemFree(abspidl);
}
}
}
}
CoTaskMemFree(pidl);
}
} while(fetched);
pEnum->Release();
}
pShellFolder->Release();
}
CoTaskMemFree(folderpidl);
}
pPersistFolder->Release();
}
pFolderView->Release();
}
pShellView->Release();
}
pShellBrowser->Release();
}
pServiceProvider->Release();
}
}
// show the rename dialog
m_bDialogShown = TRUE;
CRenameDlg dlg(hwnd);
dlg.SetFileList(m_filelist);
if (dlg.DoModal(g_hInst, IDD_RENAMEDLG, hwnd, NULL) == IDOK)
{
try
{
const std::tr1::wregex regCheck(dlg.GetMatchString(), dlg.GetRegexFlags());
NumberReplaceHandler handler(dlg.GetReplaceString());
// start renaming the files
IServiceProvider * pServiceProvider = NULL;
if (SUCCEEDED(GetIServiceProvider(hwnd, &pServiceProvider)))
{
示例7: while
const FileItemList& FileItem::getChildren()
{
// Is the file-item a folder?
if (IS_FOLDER(this) &&
// if the children list is empty, or the file-system version
// change (it's like to say: the current this->children list
// is outdated)...
(this->children.empty() ||
current_file_system_version > this->version)) {
FileItemList::iterator it;
FileItem* child;
// we have to mark current items as deprecated
for (it=this->children.begin();
it!=this->children.end(); ++it) {
child = static_cast<FileItem*>(*it);
child->removed = true;
}
//PRINTF("FS: Loading files for %p (%s)\n", fileitem, fileitem->displayname);
#ifdef USE_PIDLS
{
IShellFolder* pFolder = NULL;
if (this == rootitem)
pFolder = shl_idesktop;
else
shl_idesktop->BindToObject(this->fullpidl,
NULL,
IID_IShellFolder,
(LPVOID *)&pFolder);
if (pFolder != NULL) {
IEnumIDList *pEnum = NULL;
ULONG c, fetched;
/* get the interface to enumerate subitems */
pFolder->EnumObjects(win_get_window(),
SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pEnum);
if (pEnum != NULL) {
LPITEMIDLIST itempidl[256];
SFGAOF attribs[256];
/* enumerate the items in the folder */
while (pEnum->Next(256, itempidl, &fetched) == S_OK && fetched > 0) {
/* request the SFGAO_FOLDER attribute to know what of the
item is a folder */
for (c=0; c<fetched; ++c) {
attribs[c] = SFGAO_FOLDER;
pFolder->GetAttributesOf(1, (LPCITEMIDLIST *)itempidl, attribs+c);
}
/* generate the FileItems */
for (c=0; c<fetched; ++c) {
LPITEMIDLIST fullpidl = concat_pidl(this->fullpidl,
itempidl[c]);
child = get_fileitem_by_fullpidl(fullpidl, false);
if (!child) {
child = new FileItem(this);
child->pidl = itempidl[c];
child->fullpidl = fullpidl;
child->attrib = attribs[c];
update_by_pidl(child);
put_fileitem(child);
}
else {
ASSERT(child->parent == this);
free_pidl(fullpidl);
free_pidl(itempidl[c]);
}
this->insertChildSorted(child);
}
}
pEnum->Release();
}
if (pFolder != shl_idesktop)
pFolder->Release();
}
}
#else
{
char buf[MAX_PATH], path[MAX_PATH], tmp[32];
ustrcpy(path, this->filename.c_str());
put_backslash(path);
replace_filename(buf,
path,
uconvert_ascii("*.*", tmp),
sizeof(buf));
#ifdef WORKAROUND_64BITS_SUPPORT
// we cannot use the for_each_file's 'param' to wrap a 64-bits pointer
//.........这里部分代码省略.........
示例8: AddFileItem
bool CFileSelectList::AddFileItem(LPITEMIDLIST pFullIDLS,int nOption)
{
bool res = false;
SHFILEINFO fileInfo={0};
if(SHGetFileInfo((LPCTSTR)pFullIDLS,0,&fileInfo,sizeof(fileInfo),SHGFI_PIDL |SHGFI_DISPLAYNAME|SHGFI_ATTRIBUTES|SHGFI_ICON|SHGFI_SMALLICON) != 0)
{
if(fileInfo.dwAttributes & SFGAO_FILESYSTEM)
{
bool bIsFile = false;
if(fileInfo.dwAttributes & SFGAO_FOLDER)//判断是否是文件系统对象文件夹,排除zip文件
{
if(fileInfo.dwAttributes & SFGAO_STREAM)
{
int nSysID = GetWindowsSystemID();
if(nSysID == WINDOWS_XP || nSysID == WINDOWS_VISTA || nSysID == WINDOWS_2003)
{
bIsFile = true;//zip文件
}
}
}
else
{
bIsFile = true;
}
if(!bIsFile) //是文件夹,但不是.zip文件
{
IShellFolder *pIParentFolder,*pICurFolder;
LPITEMIDLIST pLocalIDLS;
if(nOption & UNIFOLDER_PIG)//作为整体归档
{
goto PIG_FILE;
}
else//归档下面的文件
{
if(S_OK == SHBindToParent(pFullIDLS,IID_IShellFolder,(void**)&pIParentFolder,(LPCITEMIDLIST*)&pLocalIDLS))
{
if(S_OK == pIParentFolder->BindToObject(pLocalIDLS,NULL,IID_IShellFolder,(void**)&pICurFolder))
{
IEnumIDList* pIEnum;
SHCONTF enumFlag = (nOption&FOLDER_RECURSIVEG_PIG)?(SHCONTF_FOLDERS|SHCONTF_NONFOLDERS):SHCONTF_NONFOLDERS;
if(S_OK == pICurFolder->EnumObjects(NULL,enumFlag,&pIEnum))
{
for(HRESULT call_res = pIEnum->Next(1,&pLocalIDLS,NULL);call_res == S_OK;call_res = pIEnum->Next(1,&pLocalIDLS,NULL))
{
LPITEMIDLIST pFullChildIDLST = ILCombine(pFullIDLS,pLocalIDLS);
if(pFullChildIDLST != NULL)
{
AddFileItem(pFullChildIDLST,nOption);
ILFree(pFullChildIDLST);
}
CoTaskMemFree(pLocalIDLS);
}
pIEnum->Release();
}
pICurFolder->Release();
}
pIParentFolder->Release();
}
}
}
else //is file
{
PIG_FILE:
TCHAR tcbufPath[MAX_PATH];
if(SHGetPathFromIDList(pFullIDLS,tcbufPath))
{
if(!IsAlreayIn(FilePath2Url(CString(tcbufPath))))
{
CString strPathFolder,strFName,strDriver,strExt;
SplitFilePath(CString(tcbufPath),strPathFolder,strDriver,strFName,strExt);
LVITEM lvit = {0};
lvit.mask = LVIF_IMAGE|LVIF_TEXT;
lvit.iItem = GetItemCount();
lvit.pszText = (LPWSTR)(LPCTSTR)strFName;
lvit.cchTextMax = strFName.GetLength();
int iImg;
if(!m_iSys2Self.Lookup(fileInfo.iIcon,iImg))
{
//CImageList *pImgLs = GetImageList(LVSIL_SMALL);
iImg = GetImageList(LVSIL_SMALL)->Add(fileInfo.hIcon);
m_iSys2Self.SetAt(fileInfo.iIcon,iImg);
}
lvit.iImage = iImg;
int iItem = InsertItem(&lvit);
//SetItem(iItem,1,LVIF_TEXT,strPathFolder+L"\\",0,0,0,0);
SetItemText(iItem,1,tcbufPath);
ItemDataType* pItemData = new ItemDataType;
pItemData->strItemUrl = FilePath2Url(tcbufPath);
SetItemData(iItem,(DWORD_PTR)pItemData);
//.........这里部分代码省略.........
示例9: IExtractIconW_Constructor
/**************************************************************************
* IExtractIconW_Constructor
*/
IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl)
{
CComPtr<IDefaultExtractIconInit> initIcon;
IExtractIconW *extractIcon;
GUID const * riid;
int icon_idx;
UINT flags;
CHAR sTemp[MAX_PATH];
WCHAR wTemp[MAX_PATH];
LPITEMIDLIST pSimplePidl = ILFindLastID(pidl);
HRESULT hr;
hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,&initIcon));
if (FAILED(hr))
return NULL;
hr = initIcon->QueryInterface(IID_PPV_ARG(IExtractIconW,&extractIcon));
if (FAILED(hr))
return NULL;
if (_ILIsDesktop(pSimplePidl))
{
initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DESKTOP);
}
else if ((riid = _ILGetGUIDPointer(pSimplePidl)))
{
/* my computer and other shell extensions */
static const WCHAR fmt[] = { 'C', 'L', 'S', 'I', 'D', '\\',
'{', '%', '0', '8', 'l', 'x', '-', '%', '0', '4', 'x', '-', '%', '0', '4', 'x', '-',
'%', '0', '2', 'x', '%', '0', '2', 'x', '-', '%', '0', '2', 'x', '%', '0', '2', 'x',
'%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '}', 0
};
WCHAR xriid[50];
swprintf(xriid, fmt,
riid->Data1, riid->Data2, riid->Data3,
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]);
const WCHAR* iconname = NULL;
if (_ILIsBitBucket(pSimplePidl))
{
static const WCHAR szFull[] = {'F','u','l','l',0};
static const WCHAR szEmpty[] = {'E','m','p','t','y',0};
IEnumIDList *EnumIDList = NULL;
CoInitialize(NULL);
IShellFolder2 *psfRecycleBin = NULL;
IShellFolder *psfDesktop = NULL;
hr = SHGetDesktopFolder(&psfDesktop);
if (SUCCEEDED(hr))
hr = psfDesktop->BindToObject(pSimplePidl, NULL, IID_IShellFolder2, (void**) &psfRecycleBin);
if (SUCCEEDED(hr))
hr = psfRecycleBin->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &EnumIDList);
ULONG itemcount;
LPITEMIDLIST pidl = NULL;
if (SUCCEEDED(hr) && (hr = EnumIDList->Next(1, &pidl, &itemcount)) == S_OK)
{
CoTaskMemFree(pidl);
iconname = szFull;
} else {
iconname = szEmpty;
}
if (psfDesktop)
psfDesktop->Release();
if (psfRecycleBin)
psfRecycleBin->Release();
if (EnumIDList)
EnumIDList->Release();
}
if (HCR_GetIconW(xriid, wTemp, iconname, MAX_PATH, &icon_idx))
{
initIcon->SetNormalIcon(wTemp, icon_idx);
}
else
{
if (IsEqualGUID(*riid, CLSID_MyComputer))
initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_COMPUTER);
else if (IsEqualGUID(*riid, CLSID_MyDocuments))
initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_DOCUMENTS);
else if (IsEqualGUID(*riid, CLSID_NetworkPlaces))
initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_NETWORK_PLACES);
else
initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_FOLDER);
}
}
else if (_ILIsDrive (pSimplePidl))
{
static const WCHAR drive[] = { 'D', 'r', 'i', 'v', 'e', 0 };
int icon_idx = -1;
if (_ILGetDrive(pSimplePidl, sTemp, MAX_PATH))
//.........这里部分代码省略.........
示例10: BrowseVirtualFolder
void CShellBrowser::BrowseVirtualFolder(LPITEMIDLIST pidlDirectory)
{
IShellFolder *pShellFolder = NULL;
IEnumIDList *pEnumIDList = NULL;
LPITEMIDLIST rgelt = NULL;
STRRET str;
SHCONTF EnumFlags;
TCHAR szFileName[MAX_PATH];
ULONG uFetched;
HRESULT hr;
DetermineFolderVirtual(pidlDirectory);
hr = BindToIdl(pidlDirectory, IID_PPV_ARGS(&pShellFolder));
if(SUCCEEDED(hr))
{
m_pidlDirectory = ILClone(pidlDirectory);
EnumFlags = SHCONTF_FOLDERS|SHCONTF_NONFOLDERS;
if(m_bShowHidden)
EnumFlags |= SHCONTF_INCLUDEHIDDEN;
hr = pShellFolder->EnumObjects(m_hOwner,EnumFlags,&pEnumIDList);
if(SUCCEEDED(hr) && pEnumIDList != NULL)
{
uFetched = 1;
while(pEnumIDList->Next(1,&rgelt,&uFetched) == S_OK && (uFetched == 1))
{
ULONG uAttributes = SFGAO_FOLDER;
pShellFolder->GetAttributesOf(1,(LPCITEMIDLIST *)&rgelt,&uAttributes);
/* If this is a virtual folder, only use SHGDN_INFOLDER. If this is
a real folder, combine SHGDN_INFOLDER with SHGDN_FORPARSING. This is
so that items in real folders can still be shown with extensions, even
if the global, Explorer option is disabled.
Also use only SHGDN_INFOLDER if this item is a folder. This is to ensure
that specific folders in Windows 7 (those under C:\Users\Username) appear
correctly. */
if(m_bVirtualFolder || (uAttributes & SFGAO_FOLDER))
hr = pShellFolder->GetDisplayNameOf(rgelt,SHGDN_INFOLDER,&str);
else
hr = pShellFolder->GetDisplayNameOf(rgelt,SHGDN_INFOLDER|SHGDN_FORPARSING,&str);
if(SUCCEEDED(hr))
{
StrRetToBuf(&str,rgelt,szFileName,MAX_PATH);
AddItemInternal(pidlDirectory,rgelt,szFileName,-1,FALSE);
}
CoTaskMemFree((LPVOID)rgelt);
}
pEnumIDList->Release();
}
pShellFolder->Release();
}
}
示例11: SearchFolder
void SearchFolder(IShellFolder* pSearchFolder, CDoubleList<FILE_ITEM> &Items, LARGE_INTEGER& liSize)
{
//getting the enumerator object to enumerate the items of the search folder
IEnumIDList* pEnumIDList = NULL;
HRESULT hr = pSearchFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &pEnumIDList);
if (FAILED(hr))
{
if (hr != E_ACCESSDENIED)
DisplayError(hr);
return;
}
if (hr == S_FALSE) return;
//getting pidl to each child item
ITEMIDLIST* pidlChild = NULL;
HRESULT hrEnum;
do
{
hrEnum = pEnumIDList->Next(1, &pidlChild, NULL);
if (FAILED(hrEnum))
{
pEnumIDList->Release();
_ASSERT(0);
DisplayError(hrEnum);
return;
}
if (S_FALSE == hrEnum) break;
//we need to know whether this is a folder or a file, and if it is a system item
ULONG ulFlags = 0xFFFFFFFF;
hr = pSearchFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidlChild, &ulFlags);
if (FAILED(hr))
{
CoTaskMemFree(pidlChild);
pidlChild = NULL;
pEnumIDList->Release();
_ASSERT(0);
MessageBox(0, L"Could not get the attributes of the item: pSearchFolder->GetAttributesOf", 0, 0);
return;
}
if (ulFlags & SFGAO_FILESYSTEM)
{
if (ulFlags & SFGAO_FOLDER && ulFlags & SFGAO_FILESYSANCESTOR && ulFlags & SFGAO_STORAGE)
{
//we need to search it
IShellFolder* pNewSearchFolder = NULL;
hr = pSearchFolder->BindToObject(pidlChild, NULL, IID_IShellFolder, (void**)&pNewSearchFolder);
if (FAILED(hr))
{
CoTaskMemFree(pidlChild);
pidlChild = NULL;
pEnumIDList->Release();
_ASSERT(0);
MessageBox(0, L"Could not bind to new folder: pSearchFolder->BindToObject", 0, 0);
return;
}
//it is a folder!!
//get its full name
STRRET strret;
pSearchFolder->GetDisplayNameOf(pidlChild, SHGDN_FORPARSING, &strret);
WCHAR* wsFullName;
StrRetToStrW(&strret, NULL, &wsFullName);
FILE_ITEM item;
item.size = 0;
item.wsFullName = wsFullName;
item.type = ItemType::Folder;
Items.push_back(item);
SearchFolder(pNewSearchFolder, Items, liSize);
pNewSearchFolder->Release();
}
else if (ulFlags & SFGAO_STREAM)
{
//it is a file!!
//get its full name
STRRET strret;
pSearchFolder->GetDisplayNameOf(pidlChild, SHGDN_FORPARSING, &strret);
WCHAR* wsFullName;
StrRetToStrW(&strret, NULL, &wsFullName);
FILE_ITEM item;
LARGE_INTEGER li;
CalcFileSize(wsFullName, li);
item.size = li.QuadPart;
liSize.QuadPart += item.size;
item.wsFullName = wsFullName;
item.type = ItemType::File;
Items.push_back(item);
}
}
//.........这里部分代码省略.........