本文整理汇总了C++中IServiceProvider::QueryService方法的典型用法代码示例。如果您正苦于以下问题:C++ IServiceProvider::QueryService方法的具体用法?C++ IServiceProvider::QueryService怎么用?C++ IServiceProvider::QueryService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceProvider
的用法示例。
在下文中一共展示了IServiceProvider::QueryService方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetScriptSite
//
// IActiveScript
//
HRESULT STDMETHODCALLTYPE CRScriptCore::SetScriptSite(
/* [in] */ IActiveScriptSite __RPC_FAR *pass)
{
if (!pass) return E_POINTER;
if (m_pSite) return E_UNEXPECTED;
MakeScope();
pass->AddRef();
m_pSite = pass;
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
if (m_dwSafety & INTERFACE_USES_SECURITY_MANAGER)
{
IServiceProvider* pProv = NULL;
HRESULT hr = m_pSite->QueryInterface(IID_IServiceProvider, (void**)&pProv);
if (hr == S_OK)
{
IInternetHostSecurityManager* pScm = NULL;
hr = pProv->QueryService(SID_SInternetHostSecurityManager, IID_IInternetHostSecurityManager, (void**)&pScm);
if (hr == S_OK)
{
BYTE b[_MAX_PATH];
DWORD dw(sizeof(b));
hr = pScm->GetSecurityId(b, &dw, 0);
m_pScM = pScm;
}
m_pProv = pProv;
}
}
#endif
return S_OK;
}
示例2: QueryService
//
// IServiceProvider
HRESULT STDMETHODCALLTYPE CRScriptCore::QueryService(
REFGUID guidService,
REFIID riid,
void **ppv)
{
if (!ppv) return E_POINTER;
HRESULT hr = E_NOINTERFACE;
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
if (m_listServiceProvider.size() > 0)
{
IServiceProvider* p = m_listServiceProvider.front();
hr = p->QueryService(guidService, riid, ppv);
}
else
{
*ppv = NULL;
if (InlineIsEqualGUID(guidService, SID_GetCaller)
|| InlineIsEqualGUID(guidService, IID_IActiveScriptSite))
{
IActiveScriptSite* pSite = GetSite();
if (pSite)
{
hr = pSite->QueryInterface(riid, ppv);
}
pSite->Release();
}
else if (m_pProv)
{
hr = m_pProv->QueryService(guidService, riid, ppv);
}
}
#endif
return hr;
}
示例3: 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();
}
}
示例4: versionSpecificInit
void GeckoVBufBackend_t::versionSpecificInit(IAccessible2* pacc) {
// Defaults.
this->shouldDisableTableHeaders = false;
this->hasEncodedAccDescription = false;
IServiceProvider* serv = NULL;
if (pacc->QueryInterface(IID_IServiceProvider, (void**)&serv) != S_OK)
return;
IAccessibleApplication* iaApp = NULL;
if (serv->QueryService(IID_IAccessibleApplication, IID_IAccessibleApplication, (void**)&iaApp) != S_OK) {
serv->Release();
return;
}
serv->Release();
BSTR toolkitName = NULL;
if (iaApp->get_toolkitName(&toolkitName) != S_OK) {
iaApp->Release();
return;
}
if(toolkitName) {
this->toolkitName = std::wstring(toolkitName, SysStringLen(toolkitName));
}
BSTR toolkitVersion = NULL;
if (iaApp->get_toolkitVersion(&toolkitVersion) != S_OK) {
iaApp->Release();
SysFreeString(toolkitName);
return;
}
iaApp->Release();
iaApp = NULL;
if (wcscmp(toolkitName, L"Gecko") == 0) {
if (wcsncmp(toolkitVersion, L"1.", 2) == 0) {
if (wcsncmp(toolkitVersion, L"1.9.2.", 6) == 0) {
// Gecko 1.9.2.x.
// Retrieve the digits for the final part of the main version number.
wstring verPart;
for (wchar_t* c = &toolkitVersion[6]; iswdigit(*c); c++)
verPart += *c;
if (_wtoi(verPart.c_str()) <= 10) {
// Gecko <= 1.9.2.10 will crash if we try to retrieve headers on some table cells, so disable them.
this->shouldDisableTableHeaders = true;
}
}
// Gecko 1.x uses accDescription to encode position info as well as the description.
this->hasEncodedAccDescription = true;
}
}
SysFreeString(toolkitName);
SysFreeString(toolkitVersion);
}
示例5: GetVirtualDesktopManager
HRESULT GetVirtualDesktopManager(IVirtualDesktopManagerInternal** ppDesktopManagerInternal)
{
::CoInitializeEx(NULL, COINIT_MULTITHREADED);
IServiceProvider* pServiceProvider = nullptr;
HRESULT hr = ::CoCreateInstance(
CLSID_ImmersiveShell, NULL, CLSCTX_LOCAL_SERVER,
__uuidof(IServiceProvider), (PVOID*)&pServiceProvider);
if (SUCCEEDED(hr))
{
hr = pServiceProvider->QueryService(CLSID_VirtualDesktopAPI_Unknown, ppDesktopManagerInternal);
pServiceProvider->Release();
}
return hr;
}
示例6: Cstr_message
void
ieambulant_display_message(int level, const char* message) {
USES_CONVERSION;
HRESULT hr = E_FAIL;
if ( ! s_site)
return;
IServiceProvider* pISP = NULL;
hr = s_site->QueryInterface(IID_IServiceProvider, (void **)&pISP);
if ( ! SUCCEEDED(hr))
return;
// get IWebBrowser2
IWebBrowser2* pIWebBrowser2 = NULL;
hr = pISP->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, (void **)&pIWebBrowser2);
pISP->Release();
if ( ! SUCCEEDED(hr) || pIWebBrowser2 == NULL)
return;
IDispatch *pIDispatchDocument = NULL;
hr = pIWebBrowser2->get_Document(&pIDispatchDocument);
pIWebBrowser2->Release();
if ( ! SUCCEEDED(hr) || pIDispatchDocument == NULL)
return;
// get IHTMLDocument2
IHTMLDocument2* pIHTMLDocument2 = NULL;
hr = pIDispatchDocument->QueryInterface(IID_IHTMLDocument2, (void **)&pIHTMLDocument2);
pIDispatchDocument->Release();
if ( ! SUCCEEDED(hr) || pIHTMLDocument2 == NULL)
return;
// get IHTMLWindow2
IHTMLWindow2* pIHTMLWindow2 = NULL;
hr = pIHTMLDocument2->get_parentWindow(&pIHTMLWindow2);
pIHTMLDocument2->Release();
if ( ! SUCCEEDED(hr) || pIHTMLWindow2 == NULL)
return;
CString Cstr_message(message);
BSTR BSTR_message = Cstr_message.AllocSysString();
pIHTMLWindow2->put_status(BSTR_message);
SysFreeString(BSTR_message);
pIHTMLWindow2->Release();
}
示例7:
HRESULT
Cieambulant::get_document_url() {
// here the <url> is obtained from the <PARAM name="src" value="<url>"/> element
// and joined with the base url.
// also the the value of <PARAM name="autostart" value="<true|false>"/> is retrieved.
HRESULT hr = E_FAIL;
if ( ! m_site)
return hr;
IServiceProvider* pISP = NULL;
hr = m_site->QueryInterface(IID_IServiceProvider, (void **)&pISP);
if ( ! SUCCEEDED(hr))
return hr;
IWebBrowser2* pIWebBrowser2 = NULL;
hr = pISP->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, (void **)&pIWebBrowser2);
if ( ! SUCCEEDED(hr))
return hr;
BSTR BSTR_base_url;
hr = pIWebBrowser2->get_LocationURL(&BSTR_base_url);
if ( ! SUCCEEDED(hr))
return hr;
std::string std_string_base_url = CComBSTR_to_std_string (BSTR_base_url);
SysFreeString(BSTR_base_url);
m_base_url = ambulant::net::url::from_url(std_string_base_url);
m_url = ambulant::net::url::from_url(CComBSTR_to_std_string(m_bstrSrc));
std::string std_string_autostart = CComBSTR_to_std_string(m_bstrAutostart);
if (std_string_autostart == "false"
|| std_string_autostart == "FALSE")
m_autostart = false;
return S_OK;
}
示例8: saveSnapshot
/**
* Saves a rendering of the current site by its host container as a PNG file.
* This implementation is derived from IECapt.
*
* @param outputFile the file to save the PNG output as
* @link http://iecapt.sourceforge.net/
*/
STDMETHODIMP CCoSnapsie::saveSnapshot(
BSTR outputFile,
BSTR frameId,
LONG drawableScrollWidth,
LONG drawableScrollHeight,
LONG drawableClientWidth,
LONG drawableClientHeight,
LONG drawableClientLeft,
LONG drawableClientTop,
LONG frameBCRLeft,
LONG frameBCRTop)
{
HRESULT hr;
HWND hwndBrowser;
CComPtr<IOleClientSite> spClientSite;
CComQIPtr<IServiceProvider> spISP;
CComPtr<IWebBrowser2> spBrowser;
CComPtr<IDispatch> spDispatch;
CComQIPtr<IHTMLDocument2> spDocument;
CComPtr<IHTMLWindow2> spScrollableWindow;
CComQIPtr<IViewObject2> spViewObject;
CComPtr<IHTMLStyle> spStyle;
CComQIPtr<IHTMLElement2> spScrollableElement;
CComVariant documentHeight;
CComVariant documentWidth;
CComVariant viewportHeight;
CComVariant viewportWidth;
GetSite(IID_IUnknown, (void**)&spClientSite);
if (spClientSite == NULL)
{
Error(L"There is no site.");
return E_FAIL;
}
spISP = spClientSite;
if (spISP == NULL)
{
Error(L"Unable to convert client site to service provider.");
return E_FAIL;
}
// from http://support.microsoft.com/kb/257717
hr = spISP->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, (void **)&spBrowser);
if (FAILED(hr)) {
// if we can't query the client site for IWebBrowser2, we're probably
// in an HTA. Obtain the IHTMLWindow2 interface pointer by directly
// querying the client site's service provider.
// http://groups.google.com/group/microsoft.public.vc.language/browse_thread/thread/f8987a31d47cccfe/884cb8f13423039e
CComPtr<IHTMLWindow2> spWindow;
hr = spISP->QueryService(IID_IHTMLWindow2, &spWindow);
if (FAILED(hr)) {
Error("Failed to obtain IHTMLWindow2 from service provider");
return E_FAIL;
}
hr = spWindow->get_document(&spDocument);
if (FAILED(hr)) {
Error("Failed to obtain IHTMLDocument2 from window");
return E_FAIL;
}
CComQIPtr<IOleWindow> spOleWindow = spDocument;
if (spOleWindow == NULL) {
Error("Failed to obtain IOleWindow from document");
return E_FAIL;
}
hr = spOleWindow->GetWindow(&hwndBrowser);
if (FAILED(hr)) {
Error("Failed to obtain HWND from OLE window");
return E_FAIL;
}
hwndBrowser = GetAncestor(hwndBrowser, GA_ROOTOWNER);
}
else {
hr = spBrowser->get_HWND((long*)&hwndBrowser);
if (FAILED(hr)) {
Error("Failed to get HWND for browser (is this a frame?)");
return E_FAIL;
}
ie = GetAncestor(hwndBrowser, GA_ROOTOWNER);
CComPtr<IDispatch> spDispatch;
hr = spBrowser->get_Document(&spDispatch);
if (FAILED(hr))
return E_FAIL;
//.........这里部分代码省略.........
示例9: 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;
//.........这里部分代码省略.........
示例10: Rename
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));
}
}
//.........这里部分代码省略.........
示例11: AfxGetStaticModuleState
STDMETHODIMP ExplorerBar::SetSite( IUnknown *inPunkSite )
{
AFX_MANAGE_STATE( AfxGetStaticModuleState() );
HRESULT err;
// Release the old interfaces.
if( mWebBrowser )
{
mWebBrowser->Release();
mWebBrowser = NULL;
}
if( mSite )
{
mSite->Release();
mSite = NULL;
}
// A non-NULL site means we're setting the site. Otherwise, the site is being released (done above).
if( !inPunkSite )
{
err = S_OK;
goto exit;
}
// Get the parent window.
IOleWindow * oleWindow;
mParentWindow = NULL;
err = inPunkSite->QueryInterface( IID_IOleWindow, (LPVOID *) &oleWindow );
require( SUCCEEDED( err ), exit );
err = oleWindow->GetWindow( &mParentWindow );
oleWindow->Release();
require_noerr( err, exit );
require_action( mParentWindow, exit, err = E_FAIL );
// Get the IInputObject interface.
err = inPunkSite->QueryInterface( IID_IInputObjectSite, (LPVOID *) &mSite );
require( SUCCEEDED( err ), exit );
check( mSite );
// Get the IWebBrowser2 interface.
IOleCommandTarget * oleCommandTarget;
err = inPunkSite->QueryInterface( IID_IOleCommandTarget, (LPVOID *) &oleCommandTarget );
require( SUCCEEDED( err ), exit );
IServiceProvider * serviceProvider;
err = oleCommandTarget->QueryInterface( IID_IServiceProvider, (LPVOID *) &serviceProvider );
oleCommandTarget->Release();
require( SUCCEEDED( err ), exit );
err = serviceProvider->QueryService( SID_SWebBrowserApp, IID_IWebBrowser2, (LPVOID *) &mWebBrowser );
serviceProvider->Release();
require( SUCCEEDED( err ), exit );
// Create the main window.
err = SetupWindow();
require_noerr( err, exit );
exit:
return( err );
}
示例12: HandleNoRightsEx
HRESULT HandleNoRightsEx( HRESULT hrStatus, WM_GET_LICENSE_DATA * pLicenseData )
{
HRESULT hr = S_OK;
BOOL fMonitoring = FALSE;
BSTR bstrURL = NULL;
if((NULL == pLicenseData) || (NULL == pLicenseData->wszLocalFilename))
{
return E_INVALIDARG;
}
if (FAILED(hrStatus) && (NS_E_DRM_NO_RIGHTS != hrStatus))
{
Msg(TEXT("Unable to obtain proper license!! Aborting playback...\r\n"));
hr = hrStatus;
return hr;
}
if( TRUE )
{
IServiceProvider *pServiceProvider;
JIF(g_pReader->QueryInterface(IID_IServiceProvider, (void **) &pServiceProvider));
JIF(pServiceProvider->QueryService(IID_IWMDRMReader, IID_IWMDRMReader,
(void **) &g_pDRMReader));
pServiceProvider->Release();
// do silent license acquisition
hr = g_pDRMReader->AcquireLicense(TRUE);
if (FAILED(hr))
{
Msg(TEXT("AcquireLicense Failed! hr=0x%x\n"), hr);
SAFE_RELEASE(g_pDRMReader);
return hr;
}
}
else // non-silent acquisition
{
// convert wszs to bstrs so we can pass them to core
bstrURL = SysAllocString(pLicenseData->wszLocalFilename);
if (!bstrURL)
{
hr = E_OUTOFMEMORY;
}
else
{
// start license monitoring
hr = g_pDRMReader->MonitorLicenseAcquisition();
if (FAILED(hr))
{
// wmp explicitly ignores hr here
g_pDRMReader->CancelMonitorLicenseAcquisition();
}
else
{
fMonitoring = true;
}
SysFreeString(bstrURL);
}
}
SAFE_RELEASE(g_pDRMReader);
return hr;
}
示例13: GetValue
// IExecuteCommandApplicationHostEnvironment
IFACEMETHODIMP GetValue(AHE_TYPE *aLaunchType)
{
Log(L"IExecuteCommandApplicationHostEnvironment::GetValue()");
*aLaunchType = AHE_DESKTOP;
mIsDesktopRequest = true;
if (!mUnkSite) {
Log(L"No mUnkSite.");
return S_OK;
}
HRESULT hr;
IServiceProvider* pSvcProvider = NULL;
hr = mUnkSite->QueryInterface(IID_IServiceProvider, (void**)&pSvcProvider);
if (!pSvcProvider) {
Log(L"Couldn't get IServiceProvider service from explorer. (%X)", hr);
return S_OK;
}
IExecuteCommandHost* pHost = NULL;
// If we can't get this it's a conventional desktop launch
hr = pSvcProvider->QueryService(SID_ExecuteCommandHost,
IID_IExecuteCommandHost, (void**)&pHost);
if (!pHost) {
Log(L"Couldn't get IExecuteCommandHost service from explorer. (%X)", hr);
SafeRelease(&pSvcProvider);
return S_OK;
}
SafeRelease(&pSvcProvider);
EC_HOST_UI_MODE mode;
if (FAILED(pHost->GetUIMode(&mode))) {
Log(L"GetUIMode failed.");
SafeRelease(&pHost);
return S_OK;
}
// 0 - launched from desktop
// 1 - ?
// 2 - launched from tile interface
Log(L"GetUIMode: %d", mode);
if (!IsDefaultBrowser()) {
mode = ECHUIM_DESKTOP;
}
if (mode == ECHUIM_DESKTOP) {
Log(L"returning AHE_DESKTOP");
SafeRelease(&pHost);
return S_OK;
}
SafeRelease(&pHost);
if (!IsDX10Available()) {
Log(L"returning AHE_DESKTOP because DX10 is not available");
*aLaunchType = AHE_DESKTOP;
mIsDesktopRequest = true;
} else {
Log(L"returning AHE_IMMERSIVE");
*aLaunchType = AHE_IMMERSIVE;
mIsDesktopRequest = false;
}
return S_OK;
}
示例14: 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 )
//.........这里部分代码省略.........