本文整理汇总了C++中atl::CComPtr类的典型用法代码示例。如果您正苦于以下问题:C++ CComPtr类的具体用法?C++ CComPtr怎么用?C++ CComPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CComPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetHtmlElementAttribute
GetHtmlElementAttributeResult GetHtmlElementAttribute(IHTMLElement& htmlElement,
const ATL::CComBSTR& attributeName)
{
GetHtmlElementAttributeResult retValue;
ATL::CComVariant vAttr;
ATL::CComPtr<IHTMLElement4> htmlElement4;
if (FAILED(htmlElement.QueryInterface(&htmlElement4)) || !htmlElement4)
{
return retValue;
}
ATL::CComPtr<IHTMLDOMAttribute> attributeNode;
if (FAILED(htmlElement4->getAttributeNode(attributeName, &attributeNode)) || !attributeNode)
{
return retValue;
}
// we set that attribute found but it's not necessary that we can retrieve its value
retValue.isAttributeFound = true;
if (FAILED(attributeNode->get_nodeValue(&vAttr)))
{
return retValue;
}
if (vAttr.vt == VT_BSTR && vAttr.bstrVal)
{
retValue.attributeValue = vAttr.bstrVal;
}
else if (vAttr.vt == VT_I4)
{
retValue.attributeValue = std::to_wstring(vAttr.iVal);
}
return retValue;
}
示例2: IsFlashRequest
// This is the heuristic which detects the requests issued by Flash.ocx.
// It turned out that the implementation from ''Flash.ocx'' (tested version is 15.0.0.152)
// returns quite minimal configuration in comparison with the implementation from Microsofts'
// libraries (see grfBINDF and bindInfo.dwOptions). The impl from MS often includes something
// else.
bool WBPassthruSink::IsFlashRequest(const wchar_t* const* additionalHeaders)
{
if (additionalHeaders && *additionalHeaders)
{
auto flashVersionHeader = ExtractHttpHeader<std::wstring>(*additionalHeaders, L"x-flash-version:", L"\n");
if (!TrimString(flashVersionHeader).empty())
{
return true;
}
}
ATL::CComPtr<IBindStatusCallback> bscb;
if (SUCCEEDED(QueryServiceFromClient(&bscb)) && !!bscb)
{
DWORD grfBINDF = 0;
BINDINFO bindInfo = {};
bindInfo.cbSize = sizeof(bindInfo);
if (SUCCEEDED(bscb->GetBindInfo(&grfBINDF, &bindInfo)) &&
(BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE| BINDF_PULLDATA) == grfBINDF &&
(BINDINFO_OPTIONS_ENABLE_UTF8 | BINDINFO_OPTIONS_USE_IE_ENCODING) == bindInfo.dwOptions
)
{
return true;
}
}
return false;
}
示例3: ReplaceMethodWith
HRESULT InjectedType::ReplaceMethodWith(const ModuleID moduleId, const mdToken functionToken, InstructionList &instructions, const mdSignature localVarSigTok, const unsigned minimumStackSize, ExceptionHandlerList &exceptions) const
{
IMAGE_COR_ILMETHOD* pMethodHeader = nullptr;
ULONG iMethodSize = 0;
GUARD_FAILURE_HRESULT(m_profilerInfo->GetILFunctionBody(moduleId, functionToken, (LPCBYTE*)&pMethodHeader, &iMethodSize));
Method method(pMethodHeader);
method.DeleteAllInstructions();
method.AppendInstructions(instructions);
method.SetMinimumStackSize(minimumStackSize);
if (exceptions.size() > 0)
{
method.AddExceptionHandlers(exceptions);
}
ATL::CComPtr<IMethodMalloc> methodMalloc;
GUARD_FAILURE_HRESULT(m_profilerInfo->GetILFunctionBodyAllocator(moduleId, &methodMalloc));
IMAGE_COR_ILMETHOD* pNewMethod = static_cast<IMAGE_COR_ILMETHOD*>(methodMalloc->Alloc(method.GetMethodSize()));
method.WriteMethod(pNewMethod);
if (localVarSigTok != mdSignatureNil)
{
pNewMethod->Fat.Flags |= CorILMethod_InitLocals; // always added when local variables present: http://www.liranchen.com/2010/07/behind-locals-init-flag.html
pNewMethod->Fat.LocalVarSigTok = localVarSigTok;
}
GUARD_FAILURE_HRESULT(m_profilerInfo->SetILFunctionBody(moduleId, functionToken, (LPCBYTE)pNewMethod));
return S_OK;
}
示例4: DefineAssemblyMaxVersionRef
HRESULT InjectedType::DefineAssemblyMaxVersionRef(const ModuleID moduleId, LPCWSTR assemblyName, mdModuleRef* moduleRef) const
{
ATL::CComPtr<IMetaDataAssemblyEmit> metaDataAssemblyEmit;
GUARD_FAILURE_HRESULT(GetMetaDataAssemblyEmit(moduleId, metaDataAssemblyEmit));
AssemblyReference mscorlibReference;
if (!m_assemblyRegistry->FindMaxAssemblyVersion(assemblyName, mscorlibReference))
{
return E_FAIL;
}
ASSEMBLYMETADATA mscorlibMetadata;
ZeroMemory(&mscorlibMetadata, sizeof(mscorlibMetadata));
mscorlibMetadata.usMajorVersion = mscorlibReference.version.majorVersion;
mscorlibMetadata.usMinorVersion = mscorlibReference.version.minorVersion;
mscorlibMetadata.usBuildNumber = mscorlibReference.version.buildNumber;
mscorlibMetadata.usRevisionNumber = mscorlibReference.version.revisionNumber;
const auto name = mscorlibReference.name.c_str();
return metaDataAssemblyEmit->DefineAssemblyRef(mscorlibReference.publicKeyToken,
sizeof(mscorlibReference.publicKeyToken),
name,
&mscorlibMetadata,
nullptr,
0,
0,
moduleRef);
}
示例5: ShowModeless
HRESULT CSysProgressDlg::ShowModeless(HWND hWndParent, BOOL immediately)
{
EnsureValid();
m_hWndProgDlg = NULL;
if (!IsValid())
return E_FAIL;
m_hWndParent = hWndParent;
HRESULT hr = m_pIDlg->StartProgressDialog(hWndParent, NULL, m_dwDlgFlags, NULL);
if(FAILED(hr))
return hr;
ATL::CComPtr<IOleWindow> pOleWindow;
HRESULT hr2 = m_pIDlg.QueryInterface(&pOleWindow);
if(SUCCEEDED(hr2))
{
hr2 = pOleWindow->GetWindow(&m_hWndProgDlg);
if(SUCCEEDED(hr2))
{
// see comment in ShowModal() for why we subclass the window
if (!m_isVisible)
{
m_OrigProc = (WNDPROC) SetWindowLongPtr(m_hWndProgDlg, GWLP_WNDPROC, (LONG_PTR) fnSubclass);
SetProp(m_hWndProgDlg, L"ParentWindow", m_hWndParent);
SetProp(m_hWndProgDlg, L"OrigProc", m_OrigProc);
}
if (immediately)
ShowWindow(m_hWndProgDlg, SW_SHOW);
}
}
m_isVisible = true;
return hr;
}
示例6: ShowModeless
HRESULT CSysProgressDlg::ShowModeless(HWND hWndParent, BOOL immediately)
{
EnsureValid();
m_hWndProgDlg = nullptr;
if (!IsValid())
return E_FAIL;
m_hWndParent = hWndParent;
auto winId = GetWindowThreadProcessId(m_hWndParent, 0);
auto threadId = GetCurrentThreadId();
if (winId != threadId)
AttachThreadInput(winId, threadId, TRUE);
m_hWndFocus = GetFocus();
if (winId != threadId)
AttachThreadInput(winId, threadId, FALSE);
HRESULT hr = m_pIDlg->StartProgressDialog(hWndParent, nullptr, m_dwDlgFlags, nullptr);
if(FAILED(hr))
return hr;
ATL::CComPtr<IOleWindow> pOleWindow;
HRESULT hr2 = m_pIDlg.QueryInterface(&pOleWindow);
if(SUCCEEDED(hr2))
{
hr2 = pOleWindow->GetWindow(&m_hWndProgDlg);
if(SUCCEEDED(hr2))
{
if (immediately)
ShowWindow(m_hWndProgDlg, SW_SHOW);
}
}
m_isVisible = true;
return hr;
}
示例7: DeleteJumpList
void DeleteJumpList(LPCTSTR appID)
{
ATL::CComPtr<ICustomDestinationList> pcdl;
HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, nullptr, CLSCTX_INPROC_SERVER);
if (SUCCEEDED(hr)) {
pcdl->DeleteList(appID);
}
}
示例8: ClearProvider
void ListViewAccServer::ClearProvider( HWND hControl )
{
ATL::CComPtr<IAccPropServices> pAccPropSvc;
HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
if (hr == S_OK && pAccPropSvc)
{
MSAAPROPID propid = PROPID_ACC_HELP;
pAccPropSvc->ClearHwndProps(hControl, (DWORD)OBJID_CLIENT, CHILDID_SELF, &propid, 1);
}
}
示例9: GetRVAFromKnownDefaultCtor
HRESULT InjectedType::GetRVAFromKnownDefaultCtor(ATL::CComPtr<IMetaDataImport>& metaDataImport,
const LPCWSTR knownTypeDefName,
mdTypeDef* pKnownTypeDef,
mdMethodDef* pKnownTypeDefaultCtorDef,
ULONG* pCodeRVA)
{
GUARD_FAILURE_HRESULT(metaDataImport->FindTypeDefByName(knownTypeDefName, mdTokenNil, pKnownTypeDef));
GUARD_FAILURE_HRESULT(metaDataImport->FindMethod(*pKnownTypeDef, L".ctor", ctorSignature, sizeof(ctorSignature), pKnownTypeDefaultCtorDef));
GUARD_FAILURE_HRESULT(metaDataImport->GetMethodProps(*pKnownTypeDefaultCtorDef, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr, pCodeRVA, nullptr));
return S_OK;
}
示例10: SetAccProperty
bool CCommonAppUtils::SetAccProperty(HWND hWnd, MSAAPROPID propid, const CString& text)
{
ATL::CComPtr<IAccPropServices> pAccPropSvc;
HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
if (hr == S_OK && pAccPropSvc)
{
pAccPropSvc->SetHwndPropStr(hWnd, (DWORD)OBJID_CLIENT, CHILDID_SELF, propid, text);
return true;
}
return false;
}
示例11: HasTypeDef
bool InjectedType::HasTypeDef(const ModuleID moduleId, const LPCWSTR typeDefName) const
{
ATL::CComPtr<IMetaDataImport> metaDataImport;
auto result = GetMetaDataImport(moduleId, metaDataImport);
if (result != S_OK)
{
return false;
}
mdTypeDef systemObject = mdTokenNil;
result = metaDataImport->FindTypeDefByName(typeDefName, mdTokenNil, &systemObject);
return result == S_OK;
}
示例12: ShowModal
HRESULT CSysProgressDlg::ShowModal(HWND hWndParent, BOOL immediately /* = true */)
{
EnsureValid();
m_hWndProgDlg = NULL;
if (!IsValid())
return E_FAIL;
m_hWndParent = hWndParent;
HRESULT hr = m_pIDlg->StartProgressDialog(hWndParent, NULL, m_dwDlgFlags | PROGDLG_MODAL, NULL);
if(FAILED(hr))
return hr;
ATL::CComPtr<IOleWindow> pOleWindow;
HRESULT hr2 = m_pIDlg.QueryInterface(&pOleWindow);
if(SUCCEEDED(hr2))
{
hr2 = pOleWindow->GetWindow(&m_hWndProgDlg);
if(SUCCEEDED(hr2))
{
// StartProgressDialog creates a new thread to host the progress window.
// When the window receives WM_DESTROY message StopProgressDialog() wrongly
// attempts to re-enable the parent in the calling thread (our thread),
// after the progress window is destroyed and the progress thread has died.
// When the progress window dies, the system tries to assign a new foreground window.
// It cannot assign to hwndParent because StartProgressDialog (w/PROGDLG_MODAL) disabled the parent window.
// So the system hands the foreground activation to the next process that wants it in the
// system foreground queue. Thus we lose our right to recapture the foreground window.
// The way to fix this bug is to insert a call to EnableWindow(hWndParent) in the WM_DESTROY
// handler for the progress window in the progress thread.
// To do that, we Subclass the progress dialog
// Since the window and thread created by the progress dialog object live on a few
// milliseconds after calling Stop() and Release(), we must not store anything
// in member variables of this class but must only store everything in the window
// itself: thus we use SetProp()/GetProp() to store the data.
if (!m_isVisible)
{
m_OrigProc = (WNDPROC) SetWindowLongPtr(m_hWndProgDlg, GWLP_WNDPROC, (LONG_PTR) fnSubclass);
SetProp(m_hWndProgDlg, L"ParentWindow", m_hWndParent);
SetProp(m_hWndProgDlg, L"OrigProc", m_OrigProc);
}
if(immediately)
ShowWindow(m_hWndProgDlg, SW_SHOW);
}
}
m_isVisible = true;
return hr;
}
示例13: IsItemInArray
bool IsItemInArray(IShellItem *psi, IObjectArray *poaRemoved)
{
UINT cItems;
if (FAILED(poaRemoved->GetCount(&cItems)))
return false;
bool fRet = false;
for (UINT i = 0; !fRet && i < cItems; i++) {
ATL::CComPtr<IShellItem> psiCompare;
if (FAILED(poaRemoved->GetAt(i, IID_PPV_ARGS(&psiCompare))))
continue;
int iOrder;
fRet = SUCCEEDED(psiCompare->Compare(psi, SICHINT_CANONICAL, &iOrder)) && (0 == iOrder);
}
return fRet;
}
示例14: CreateShellLink
HRESULT CreateShellLink(PCWSTR pszArguments, PCWSTR pszTitle, int iconIndex, IShellLink **ppsl)
{
ATL::CComPtr<IShellLink> psl;
HRESULT hr = psl.CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER);
if (FAILED(hr))
return hr;
WCHAR szAppPath[MAX_PATH];
if (GetModuleFileName(NULL, szAppPath, _countof(szAppPath)) == 0)
{
hr = HRESULT_FROM_WIN32(GetLastError());
return hr;
}
hr = psl->SetPath(szAppPath);
if (FAILED(hr))
return hr;
hr = psl->SetArguments(pszArguments);
if (FAILED(hr))
return hr;
hr = psl->SetIconLocation(szAppPath, iconIndex);
if (FAILED(hr))
return hr;
ATL::CComPtr<IPropertyStore> pps;
hr = psl.QueryInterface(&pps);
if (FAILED(hr))
return hr;
PROPVARIANT propvar;
hr = InitPropVariantFromString(pszTitle, &propvar);
if (SUCCEEDED(hr))
{
hr = pps->SetValue(PKEY_Title, propvar);
if (SUCCEEDED(hr))
{
hr = pps->Commit();
if (SUCCEEDED(hr))
{
hr = psl.QueryInterface(ppsl);
}
}
PropVariantClear(&propvar);
}
return hr;
}
示例15: CreateInstance
//
// IClassFactory implementation
//
HRESULT __stdcall CFactory::CreateInstance(IUnknown* pUnknownOuter, const IID& iid, void** ppv)
{
if (!ppv)
return E_POINTER;
// Cannot aggregate.
if (pUnknownOuter)
return CLASS_E_NOAGGREGATION ;
// Create component.
ATL::CComPtr<GitWCRev> pA;
pA.Attach(new (std::nothrow) GitWCRev()); // refcount set to 1 in constructor
if (!pA)
return E_OUTOFMEMORY ;
return pA->QueryInterface(iid, ppv);
}