本文整理汇总了C++中IShellView类的典型用法代码示例。如果您正苦于以下问题:C++ IShellView类的具体用法?C++ IShellView怎么用?C++ IShellView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IShellView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ZeroMemory
/**************************************************************************
* ISF_NetConnect_fnCreateViewObject
*/
HRESULT WINAPI CNetworkConnections::CreateViewObject(
HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
{
CSFV cvf;
HRESULT hr = E_NOINTERFACE;
if (!ppvOut)
return hr;
*ppvOut = NULL;
if (IsEqualIID(riid, IID_IShellView))
{
ZeroMemory(&cvf, sizeof(cvf));
cvf.cbSize = sizeof(cvf);
cvf.pshf = static_cast<IShellFolder*>(this);
IShellView* pShellView;
hr = SHCreateShellFolderViewEx(&cvf, &pShellView);
if (SUCCEEDED(hr))
{
hr = pShellView->QueryInterface(riid, ppvOut);
pShellView->Release();
}
}
return hr;
}
示例2: MyShellDispatch_ShellDispatchProc
static int MyShellDispatch_ShellDispatchProc(const shell_dispatch_handler_t handler, void *const data)
{
int iSuccess = SHELL_DISPATCH_FAILED;
IShellWindows *psw = NULL;
HRESULT hr = CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw));
if(SUCCEEDED(hr))
{
HWND desktopHwnd = 0;
IDispatch* pdisp = NULL;
variant_t vEmpty;
if(S_OK == psw->FindWindowSW(vEmpty, vEmpty, SWC_DESKTOP, (long*)&desktopHwnd, SWFO_NEEDDISPATCH, &pdisp))
{
if(VALID_HANDLE(desktopHwnd))
{
IShellBrowser *psb;
hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb));
if(SUCCEEDED(hr))
{
IShellView *psv = NULL;
hr = psb->QueryActiveShellView(&psv);
if(SUCCEEDED(hr))
{
IDispatch *pdispBackground = NULL;
HRESULT hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
if(SUCCEEDED(hr))
{
MyShellDispatch_AllowSetForegroundWindow(desktopHwnd);
IShellFolderViewDual *psfvd = NULL;
HRESULT hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
if(SUCCEEDED(hr))
{
IDispatch *pdisp = NULL;
hr = psfvd->get_Application(&pdisp);
if(SUCCEEDED(hr))
{
IShellDispatch2 *pShellDispatch;
hr = pdisp->QueryInterface(IID_PPV_ARGS(&pShellDispatch));
if(SUCCEEDED(hr))
{
iSuccess = handler(pShellDispatch, data);
}
RELEASE_OBJ(pdisp);
}
RELEASE_OBJ(psfvd);
}
RELEASE_OBJ(pdispBackground);
}
RELEASE_OBJ(psv);
}
RELEASE_OBJ(psb);
}
}
RELEASE_OBJ(pdisp);
}
RELEASE_OBJ(psw);
}
return iSuccess;
}
示例3: GetI
// @pymethod |PyIShellView|SelectItem|Description of SelectItem.
PyObject *PyIShellView::SelectItem(PyObject *self, PyObject *args)
{
IShellView *pISV = GetI(self);
if ( pISV == NULL )
return NULL;
// @pyparm <o PyIDL>|pidlItem||Description for pidlItem
// @pyparm int|uFlags||Description for uFlags
PyObject *obpidlItem;
INT iuFlags;
LPITEMIDLIST pidlItem;
SVSIF uFlags;
if ( !PyArg_ParseTuple(args, "Oi:SelectItem", &obpidlItem, &iuFlags) )
return NULL;
BOOL bPythonIsHappy = TRUE;
if (bPythonIsHappy && !PyObject_AsPIDL(obpidlItem, &pidlItem, TRUE)) bPythonIsHappy = FALSE;
uFlags = iuFlags;
if (!bPythonIsHappy) return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pISV->SelectItem( pidlItem, uFlags );
PyObject_FreePIDL(pidlItem);
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pISV, IID_IShellView );
Py_INCREF(Py_None);
return Py_None;
}
示例4: if
void CDeskBand::Rename(HWND hwnd, const std::map<std::wstring, ULONG>& items)
{
// fill the list of selected file/foldernames
m_filelist.clear();
if (items.size() > 1)
{
for (std::map<std::wstring, ULONG>::const_iterator it = items.begin(); it != items.end(); ++it)
{
size_t pos = it->first.find_last_of('\\');
if (pos != std::wstring::npos)
{
m_filelist.insert(it->first.substr(pos+1));
}
}
}
else if (items.size() == 1)
{
for (std::map<std::wstring, ULONG>::const_iterator it = items.begin(); it != items.end(); ++it)
{
size_t pos = it->first.find_last_of('\\');
if (pos != std::wstring::npos)
{
m_filelist.insert(it->first.substr(pos+1));
}
}
}
else
{
// no files or only one file were selected.
// use all files and folders in the current folder instead
IServiceProvider * pServiceProvider = NULL;
if (SUCCEEDED(GetIServiceProvider(hwnd, &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)))
{
// find all selected items
IEnumIDList * pEnum;
if (SUCCEEDED(pFolderView->Items(SVGIO_ALLVIEW, IID_IEnumIDList, (LPVOID*)&pEnum)))
{
LPITEMIDLIST pidl;
WCHAR buf[MAX_PATH] = {0};
ULONG fetched = 0;
ULONG attribs = 0;
do
{
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));
}
}
//.........这里部分代码省略.........
示例5: 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();
}
}
示例6: GetDesktopShellView
static HRESULT GetDesktopShellView(
__in REFIID riid,
__out void **ppv
)
{
HRESULT hr = S_OK;
IShellWindows* psw = NULL;
HWND hwnd = NULL;
IDispatch* pdisp = NULL;
VARIANT vEmpty = {}; // VT_EMPTY
IShellBrowser* psb = NULL;
IShellFolder* psf = NULL;
IShellView* psv = NULL;
// use the shell view for the desktop using the shell windows automation to find the
// desktop web browser and then grabs its view
// returns IShellView, IFolderView and related interfaces
hr = ::CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw));
ExitOnFailure(hr, "Failed to get shell view.");
hr = psw->FindWindowSW(&vEmpty, &vEmpty, SWC_DESKTOP, (long*)&hwnd, SWFO_NEEDDISPATCH, &pdisp);
if (S_OK == hr)
{
hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb));
ExitOnFailure(hr, "Failed to get desktop window.");
hr = psb->QueryActiveShellView(&psv);
ExitOnFailure(hr, "Failed to get active shell view.");
hr = psv->QueryInterface(riid, ppv);
ExitOnFailure(hr, "Failed to query for the desktop shell view.");
}
else if (S_FALSE == hr)
{
//Windows XP
hr = SHGetDesktopFolder(&psf);
ExitOnFailure(hr, "Failed to get desktop folder.");
hr = psf->CreateViewObject(NULL, IID_IShellView, ppv);
ExitOnFailure(hr, "Failed to query for the desktop shell view.");
}
else
{
ExitOnFailure(hr, "Failed to get desktop window.");
}
LExit:
ReleaseObject(psv);
ReleaseObject(psb);
ReleaseObject(psf);
ReleaseObject(pdisp);
ReleaseObject(psw);
return hr;
}
示例7: GetI
// @pymethod |PyIShellBrowser|OnViewWindowActive|Callback triggered when a view window is activated
PyObject *PyIShellBrowser::OnViewWindowActive(PyObject *self, PyObject *args)
{
IShellBrowser *pISB = GetI(self);
if ( pISB == NULL )
return NULL;
// @pyparm <o PyIShellView>|pshv||The activated view object
PyObject *obpshv;
IShellView *pshv;
if ( !PyArg_ParseTuple(args, "O:OnViewWindowActive", &obpshv) )
return NULL;
if (!PyCom_InterfaceFromPyInstanceOrObject(obpshv, IID_IShellView, (void **)&pshv, TRUE /* bNoneOK */))
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pISB->OnViewWindowActive( pshv );
if (pshv) pshv->Release();
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser );
Py_INCREF(Py_None);
return Py_None;
}
示例8: InvokeCommand
HRESULT WINAPI CRecycleBin::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
{
HRESULT hr;
LPSHELLBROWSER lpSB;
IShellView * lpSV = NULL;
TRACE("%p %p verb %p\n", this, lpcmi, lpcmi->lpVerb);
if (LOWORD(lpcmi->lpVerb) == iIdEmpty)
{
// FIXME
// path & flags
hr = SHEmptyRecycleBinW(lpcmi->hwnd, L"C:\\", 0);
TRACE("result %x\n", hr);
if (hr != S_OK)
return hr;
lpSB = (LPSHELLBROWSER)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER, 0, 0);
if (lpSB && SUCCEEDED(lpSB->QueryActiveShellView(&lpSV)))
lpSV->Refresh();
}
return S_OK;
}
示例9: ShellExecInExplorerProcess
HRESULT ShellExecInExplorerProcess(PCWSTR pszFile)
{
IShellView *psv;
HRESULT hr = GetShellViewForDesktop(IID_PPV_ARGS(&psv));
if (SUCCEEDED(hr))
{
IShellDispatch2 *psd;
hr = GetShellDispatchFromView(psv, IID_PPV_ARGS(&psd));
if (SUCCEEDED(hr))
{
BSTR bstrFile = SysAllocString(pszFile);
hr = bstrFile ? S_OK : E_OUTOFMEMORY;
if (SUCCEEDED(hr))
{
VARIANT vtEmpty = {}; // VT_EMPTY
hr = psd->ShellExecuteW(bstrFile, vtEmpty, vtEmpty, vtEmpty, vtEmpty);
SysFreeString(bstrFile);
}
psd->Release();
}
psv->Release();
}
return hr;
}
示例10: GetShellViewForDesktop
HRESULT GetShellViewForDesktop(REFIID riid, void **ppv)
{
*ppv = NULL;
IShellWindows *psw;
HRESULT hr = CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw));
if (SUCCEEDED(hr))
{
HWND hwnd;
IDispatch* pdisp;
VARIANT vEmpty = {}; // VT_EMPTY
if (S_OK == psw->FindWindowSW(&vEmpty, &vEmpty, SWC_DESKTOP, (long*)&hwnd, SWFO_NEEDDISPATCH, &pdisp))
{
IShellBrowser *psb;
hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb));
if (SUCCEEDED(hr))
{
IShellView *psv;
hr = psb->QueryActiveShellView(&psv);
if (SUCCEEDED(hr))
{
hr = psv->QueryInterface(riid, ppv);
psv->Release();
}
psb->Release();
}
pdisp->Release();
}
else
{
hr = E_FAIL;
}
psw->Release();
}
return hr;
}
示例11: CONTEXT
void ShellBrowser::UpdateFolderView(IShellFolder* folder)
{
CONTEXT("ShellBrowser::UpdateFolderView()");
FOLDERSETTINGS fs;
IShellView* pLastShellView = _pShellView;
_folder = folder;
if (pLastShellView)
pLastShellView->GetCurrentInfo(&fs);
else {
fs.ViewMode = _create_info._open_mode&OWM_DETAILS? FVM_DETAILS: FVM_ICON;
fs.fFlags = FWF_NOCLIENTEDGE|FWF_BESTFITWINDOW;
}
#ifndef __MINGW32__ // IShellFolderViewCB missing in MinGW (as of 25.09.2005)
SFV_CREATE sfv_create;
sfv_create.cbSize = sizeof(SFV_CREATE);
sfv_create.pshf = folder;
sfv_create.psvOuter = NULL;
sfv_create.psfvcb = this;
HRESULT hr = SHCreateShellFolderView(&sfv_create, &_pShellView);
#else
HRESULT hr = folder->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView);
#endif
if (FAILED(hr)) {
_pShellView = NULL;
return;
}
RECT rect = {CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT};
hr = _pShellView->CreateViewWindow(pLastShellView, &fs, static_cast<IShellBrowser*>(this), &rect, &_right_hwnd/*&m_hWndListView*/);
if (pLastShellView) {
pLastShellView->GetCurrentInfo(&fs);
pLastShellView->UIActivate(SVUIA_DEACTIVATE);
pLastShellView->DestroyViewWindow();
pLastShellView->Release();
}
_pShellView->UIActivate(SVUIA_ACTIVATE_NOFOCUS);
}
示例12: CONTEXT
void ShellBrowserChild::UpdateFolderView(IShellFolder* folder)
{
CONTEXT("ShellBrowserChild::UpdateFolderView()");
FOLDERSETTINGS fs;
IShellView* pLastShellView = _pShellView;
_folder = folder;
if (pLastShellView)
pLastShellView->GetCurrentInfo(&fs);
else {
fs.ViewMode = _create_info._open_mode&OWM_DETAILS? FVM_DETAILS: FVM_ICON;
fs.fFlags = FWF_BESTFITWINDOW;
}
HRESULT hr = folder->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView);
if (FAILED(hr)) {
_pShellView = NULL;
return;
}
RECT rect = {CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT};
hr = _pShellView->CreateViewWindow(pLastShellView, &fs, static_cast<IShellBrowser*>(this), &rect, &_right_hwnd/*&m_hWndListView*/);
if (pLastShellView) {
pLastShellView->GetCurrentInfo(&fs);
pLastShellView->UIActivate(SVUIA_DEACTIVATE);
pLastShellView->DestroyViewWindow();
pLastShellView->Release();
resize_children();
}
_pShellView->UIActivate(SVUIA_ACTIVATE_NOFOCUS);
}
示例13: Filter
bool CDeskBand::Filter(LPTSTR filter)
{
bool bReturn = 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 :)
IShellFolderView * pShellFolderView;
if (SUCCEEDED(pShellView->QueryInterface(IID_IShellFolderView, (LPVOID*)&pShellFolderView)))
{
// the first thing we do is to deselect all already selected entries
pFolderView->SelectItem(NULL, SVSI_DESELECTOTHERS);
// but we also need the IShellFolder interface because
// we need its GetDisplayNameOf() method
IPersistFolder2 * pPersistFolder;
if (SUCCEEDED(pFolderView->GetFolder(IID_IPersistFolder2, (LPVOID*)&pPersistFolder)))
{
LPITEMIDLIST curFolder;
pPersistFolder->GetCurFolder(&curFolder);
if (ILIsEqual(m_currentFolder, curFolder))
{
CoTaskMemFree(curFolder);
}
else
{
CoTaskMemFree(m_currentFolder);
m_currentFolder = curFolder;
for (size_t i=0; i<m_noShows.size(); ++i)
{
CoTaskMemFree(m_noShows[i]);
}
m_noShows.clear();
}
IShellFolder * pShellFolder;
if (SUCCEEDED(pPersistFolder->QueryInterface(IID_IShellFolder, (LPVOID*)&pShellFolder)))
{
// our next task is to enumerate all the
// items in the folder view and select those
// which match the text in the edit control
bool bUseRegex = (filter[0] == '\\');
try
{
const std::tr1::wregex regCheck(&filter[1], std::tr1::regex_constants::icase | std::tr1::regex_constants::ECMAScript);
}
catch (std::exception)
{
bUseRegex = false;
}
if (!bUseRegex)
{
// force the filter to lowercase
TCHAR * pString = filter;
while (*pString)
{
*pString = _totlower(*pString);
pString++;
}
}
int nCount = 0;
if (SUCCEEDED(pFolderView->ItemCount(SVGIO_ALLVIEW, &nCount)))
{
pShellFolderView->SetRedraw(FALSE);
HWND listView = GetListView32(pShellView);
LRESULT viewType = 0;
if (listView)
{
// inserting items in the list view if the list view is set to
// e.g., LV_VIEW_LIST is painfully slow. So save the current view
// and set it to LV_VIEW_DETAILS (which is much faster for inserting)
// and restore the view after we're done.
viewType = SendMessage(listView, LVM_GETVIEW, 0, 0);
SendMessage(listView, LVM_SETVIEW, LV_VIEW_DETAILS, 0);
}
std::vector<LPITEMIDLIST> noShows;
for (int i=0; i<nCount; ++i)
{
LPITEMIDLIST pidl;
if (SUCCEEDED(pFolderView->Item(i, &pidl)))
{
if (CheckDisplayName(pShellFolder, pidl, filter, bUseRegex))
{
// remove now shown items which are in the no-show list
// this is necessary since we don't get a notification
// if the shell refreshes its view
for (std::vector<LPITEMIDLIST>::iterator it = m_noShows.begin(); it != m_noShows.end(); ++it )
//.........这里部分代码省略.........
示例14: wxASSERT
void FileDialog::FilterFiles(HWND hDlg, bool refresh)
{
HWND parent = ::GetParent(hDlg);
IShellFolder *ishell = NULL;
IShellBrowser *ishellbrowser = NULL; // Does not have to be released
IShellView *ishellview = NULL;
IFolderView *ifolderview = NULL;
LPMALLOC imalloc = NULL;
HRESULT hr;
// Get pointer to the ListView control
HWND lv = ::GetDlgItem(::GetDlgItem(parent, lst2), 1);
if (lv == NULL)
{
wxASSERT(lv != NULL);
return;
}
// Get shell's memory allocation interface (must be Release()'d)
hr = SHGetMalloc(&imalloc);
if ((hr != NOERROR) || (imalloc == NULL))
{
wxASSERT((hr == NOERROR) && (imalloc != NULL));
return;
}
// Get IShellBrowser interface for current dialog
ishellbrowser = (IShellBrowser*)::SendMessage(parent, WM_GETISHELLBROWSER, 0, 0);
if (ishellbrowser)
{
// Get IShellBrowser interface for returned browser
if (ishellbrowser->QueryActiveShellView(&ishellview) == S_OK)
{
// Get the IFolderView interface...available on XP or greater
ishellview->QueryInterface(IID_IFolderView, (void **)&ifolderview);
}
}
// Init
LVITEM lvi;
wxZeroMemory(lvi);
// Process all items
int fltcnt = (int) m_Filters.GetCount();
int itmcnt = ::SendMessage(lv, LVM_GETITEMCOUNT, 0, 0);
for (int itm = 0; itm < itmcnt; itm++)
{
// Retrieve the file IDL
lvi.iItem = itm;
lvi.mask = LVIF_PARAM;
if (ListView_GetItem(lv, &lvi) != TRUE)
{
wxASSERT(FALSE);
break;
}
LPCITEMIDLIST fidl = (LPCITEMIDLIST) lvi.lParam;
// On Vista, lParam no longer contains the pidl so retrieve it via the
// IFolderView interface. This interface is only available on XP or higher
// so if that limitation isn't workable, use IShellView::GetItemObject() to
// retrieve items.
if (fidl == NULL && ifolderview != NULL)
{
ifolderview->Item(itm, (LPITEMIDLIST *) &fidl);
}
if (fidl == NULL)
{
wxASSERT(fidl != NULL);
break;
}
// Retrieve the IShellFolder interface of the parent (must be Release()'d)
if (ishell == NULL)
{
hr = SHBindToParentLocal(fidl, IID_IShellFolder, (void **)&ishell, NULL);
if (!SUCCEEDED(hr))
{
wxASSERT(SUCCEEDED(hr));
break;
}
}
// Get the attributes of the object
DWORD attr = SFGAO_FOLDER | SFGAO_BROWSABLE;
hr = ishell->GetAttributesOf(1, &fidl, &attr);
if (!SUCCEEDED(hr))
{
wxASSERT(SUCCEEDED(hr));
break;
}
// Allow all folders (things like zip files get filtered below)
if ((attr & (SFGAO_FOLDER)) && !(attr & SFGAO_BROWSABLE))
{
continue;
}
// Retrieve the parsable name of the object (includes extension)
//.........这里部分代码省略.........
示例15: ShellExecAsUser_ShellDispatchProc
static int ShellExecAsUser_ShellDispatchProc(const TCHAR *pcOperation, const TCHAR *pcFileName, const TCHAR *pcParameters, const HWND parentHwnd)
{
int iSuccess = SHELLEXECASUSER_ERROR_FAILED;
IShellWindows *psw = NULL;
HRESULT hr = CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw));
if(SUCCEEDED(hr))
{
HWND hwnd = 0;
IDispatch* pdisp = NULL;
variant_t vEmpty;
if(S_OK == psw->FindWindowSW(vEmpty, vEmpty, SWC_DESKTOP, (long*)&hwnd, SWFO_NEEDDISPATCH, &pdisp))
{
if((hwnd != NULL) && (hwnd != INVALID_HANDLE_VALUE))
{
IShellBrowser *psb;
hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb));
if(SUCCEEDED(hr))
{
IShellView *psv = NULL;
hr = psb->QueryActiveShellView(&psv);
if(SUCCEEDED(hr))
{
IDispatch *pdispBackground = NULL;
HRESULT hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
if (SUCCEEDED(hr))
{
IShellFolderViewDual *psfvd = NULL;
hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
if (SUCCEEDED(hr))
{
IDispatch *pdisp = NULL;
hr = psfvd->get_Application(&pdisp);
if (SUCCEEDED(hr))
{
IShellDispatch2 *psd;
hr = pdisp->QueryInterface(IID_PPV_ARGS(&psd));
if(SUCCEEDED(hr))
{
DispatchPendingMessages(125);
variant_t verb(pcOperation);
variant_t file(pcFileName);
variant_t para(pcParameters);
variant_t show(SW_SHOWNORMAL);
hr = psd->ShellExecute(file, para, vEmpty, verb, show);
if(SUCCEEDED(hr))
{
iSuccess = SHELLEXECASUSER_ERROR_SUCCESS;
}
psd->Release();
psd = NULL;
}
pdisp->Release();
pdisp = NULL;
}
}
pdispBackground->Release();
pdispBackground = NULL;
}
psv->Release();
psv = NULL;
}
psb->Release();
psb = NULL;
}
}
pdisp->Release();
pdisp = NULL;
}
psw->Release();
psw = NULL;
}
return iSuccess;
}