本文整理汇总了C++中IServiceProvider类的典型用法代码示例。如果您正苦于以下问题:C++ IServiceProvider类的具体用法?C++ IServiceProvider怎么用?C++ IServiceProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IServiceProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: MakeScope
//
// 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;
}
示例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: PopServiceProvider
void CRScriptCore::PopServiceProvider()
{
IServiceProvider* p = NULL;
s_crit.Lock();
if (m_listServiceProvider.size() > 0)
{
p = m_listServiceProvider.front();
m_listServiceProvider.pop_front();
}
s_crit.Unlock();
if (p)
p->Release();
}
示例6: getDocPagination
IPDDomDocPagination* getDocPagination(IAccessible* pacc, VARIANT& varChild) {
IServiceProvider* servProv;
if (pacc->QueryInterface(IID_IServiceProvider, (void**)&servProv) != S_OK)
return NULL;
IPDDomNode* domNode = getPDDomNode(varChild, servProv);
servProv->Release();
if (!domNode)
return NULL;
IPDDomDocPagination* ret;
if (domNode->QueryInterface(IID_IPDDomDocPagination, (void**)&ret) != S_OK)
ret = NULL;
domNode->Release();
return ret;
}
示例7: 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;
}
示例8: ieambulant_display_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();
}
示例9: CHECK_IE_PFN
// @pymethod <o PyIInternetSecurityManager>|internet|CoInternetCreateSecurityManager|
static PyObject *PyCoInternetCreateSecurityManager(PyObject *self, PyObject *args)
{
CHECK_IE_PFN(CoInternetCreateSecurityManager);
PyObject *obprov;
DWORD reserved;
if (!PyArg_ParseTuple(args, "Oi",
&obprov, // &pyparm <o PyIServiceProvider>|serviceProvider||
&reserved)) // @pyparm int|reserved||
return NULL;
IServiceProvider *prov;
if (!PyCom_InterfaceFromPyInstanceOrObject(obprov, IID_IServiceProvider, (void **)&prov, TRUE /* bNoneOK */))
return NULL;
HRESULT hr;
IInternetSecurityManager *sm = 0;
PY_INTERFACE_PRECALL;
hr = (*pfnCoInternetCreateSecurityManager)(prov, &sm, reserved);
prov->Release();
PY_INTERFACE_POSTCALL;
if (FAILED(hr))
return PyCom_BuildPyException(hr);
return PyCom_PyObjectFromIUnknown(sm, IID_IInternetSecurityManager, FALSE);
}
示例10:
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;
}
示例11: LOG_DEBUG
AdobeAcrobatVBufStorage_controlFieldNode_t* AdobeAcrobatVBufBackend_t::fillVBuf(int docHandle, IAccessible* pacc, VBufStorage_buffer_t* buffer,
AdobeAcrobatVBufStorage_controlFieldNode_t* parentNode, VBufStorage_fieldNode_t* previousNode,
AdobeAcrobatVBufStorage_controlFieldNode_t* oldNode,
TableInfo* tableInfo, wstring* pageNum
) {
int res;
LOG_DEBUG(L"Entered fillVBuf, with pacc at "<<pacc<<L", parentNode at "<<parentNode<<L", previousNode "<<previousNode);
nhAssert(buffer); //buffer can't be NULL
nhAssert(!parentNode||buffer->isNodeInBuffer(parentNode)); //parent node must be in buffer
nhAssert(!previousNode||buffer->isNodeInBuffer(previousNode)); //Previous node must be in buffer
VBufStorage_fieldNode_t* tempNode;
//all IAccessible methods take a variant for childID, get one ready
VARIANT varChild;
varChild.vt=VT_I4;
varChild.lVal=0;
IServiceProvider* servprov = NULL;
LOG_DEBUG(L"calling IAccessible::QueryInterface with IID_IServiceProvider");
if((res=pacc->QueryInterface(IID_IServiceProvider,(void**)(&servprov)))!=S_OK) {
LOG_DEBUG(L"IAccessible::QueryInterface returned "<<res);
return NULL;
}
LOG_DEBUG(L"IServiceProvider at "<<servprov);
// GET ID
int ID = getAccID(servprov);
nhAssert(ID);
//Make sure that we don't already know about this object -- protect from loops
if(buffer->getControlFieldNodeWithIdentifier(docHandle,ID)!=NULL) {
LOG_DEBUG(L"A node with this docHandle and ID already exists, returning NULL");
servprov->Release();
return NULL;
}
//Add this node to the buffer
LOG_DEBUG(L"Adding Node to buffer");
AdobeAcrobatVBufStorage_controlFieldNode_t* oldParentNode = parentNode;
parentNode = static_cast<AdobeAcrobatVBufStorage_controlFieldNode_t*>(buffer->addControlFieldNode(parentNode, previousNode,
new AdobeAcrobatVBufStorage_controlFieldNode_t(docHandle, ID, true)));
nhAssert(parentNode); //new node must have been created
previousNode=NULL;
LOG_DEBUG(L"Added node at "<<parentNode);
// Get role with accRole
long role = 0;
LOG_DEBUG(L"Get role with accRole");
{
wostringstream s;
VARIANT varRole;
VariantInit(&varRole);
if((res=pacc->get_accRole(varChild,&varRole))!=S_OK) {
LOG_DEBUG(L"accRole returned code "<<res);
s<<0;
} else if(varRole.vt==VT_BSTR) {
LOG_DEBUG(L"Got role string of " << varRole.bstrVal);
s << varRole.bstrVal;
} else if(varRole.vt==VT_I4) {
LOG_DEBUG(L"Got role of " << varRole.lVal);
s << varRole.lVal;
role = varRole.lVal;
}
parentNode->addAttribute(L"IAccessible::role",s.str().c_str());
VariantClear(&varRole);
}
// Get states with accState
LOG_DEBUG(L"get states with IAccessible::get_accState");
varChild.lVal=0;
VARIANT varState;
VariantInit(&varState);
if((res=pacc->get_accState(varChild,&varState))!=S_OK) {
LOG_DEBUG(L"pacc->get_accState returned "<<res);
varState.vt=VT_I4;
varState.lVal=0;
}
int states=varState.lVal;
VariantClear(&varState);
LOG_DEBUG(L"states is "<<states);
//Add each state that is on, as an attrib
for(int i=0;i<32;++i) {
int state=1<<i;
if(state&states) {
wostringstream nameStream;
nameStream<<L"IAccessible::state_"<<state;
parentNode->addAttribute(nameStream.str().c_str(),L"1");
}
}
IPDDomNode* domNode = getPDDomNode(varChild, servprov);
IPDDomElement* domElement = NULL;
LOG_DEBUG(L"Trying to get IPDDomElement");
if (domNode && (res = domNode->QueryInterface(IID_IPDDomElement, (void**)(&domElement))) != S_OK) {
LOG_DEBUG(L"QueryInterface to IPDDomElement returned " << res);
domElement = NULL;
}
BSTR stdName = NULL;
//.........这里部分代码省略.........
示例12: 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;
//.........这里部分代码省略.........
示例13: 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));
}
}
//.........这里部分代码省略.........
示例14: 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;
}
示例15: 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;
}