本文整理汇总了C++中atl::CComPtr::QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ CComPtr::QueryInterface方法的具体用法?C++ CComPtr::QueryInterface怎么用?C++ CComPtr::QueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atl::CComPtr
的用法示例。
在下文中一共展示了CComPtr::QueryInterface方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateShellLink
HRESULT CreateShellLink(PCWSTR pszArguments, PCWSTR pszTitle, int iconIndex, IShellLink **ppsl)
{
ATL::CComPtr<IShellLink> psl;
HRESULT hr = psl.CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER);
if (FAILED(hr))
return hr;
WCHAR szAppPath[MAX_PATH] = {0};
if (GetModuleFileName(nullptr, szAppPath, ARRAYSIZE(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;
}
示例2: 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);
}
示例3: DoInitializeJumpList
void CTortoiseProcApp::DoInitializeJumpList(const CString& appid)
{
ATL::CComPtr<ICustomDestinationList> pcdl;
HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER);
if (FAILED(hr))
return;
hr = pcdl->SetAppID(appid);
if (FAILED(hr))
return;
UINT uMaxSlots;
ATL::CComPtr<IObjectArray> poaRemoved;
hr = pcdl->BeginList(&uMaxSlots, IID_PPV_ARGS(&poaRemoved));
if (FAILED(hr))
return;
ATL::CComPtr<IObjectCollection> poc;
hr = poc.CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER);
if (FAILED(hr))
return;
CString sTemp = CString(MAKEINTRESOURCE(IDS_MENUSETTINGS));
CStringUtils::RemoveAccelerators(sTemp);
ATL::CComPtr<IShellLink> psl;
hr = CreateShellLink(_T("/command:settings"), (LPCTSTR)sTemp, 20, &psl);
if (SUCCEEDED(hr)) {
poc->AddObject(psl);
}
sTemp = CString(MAKEINTRESOURCE(IDS_MENUHELP));
CStringUtils::RemoveAccelerators(sTemp);
psl.Release(); // Need to release the object before calling operator&()
hr = CreateShellLink(_T("/command:help"), (LPCTSTR)sTemp, 19, &psl);
if (SUCCEEDED(hr)) {
poc->AddObject(psl);
}
ATL::CComPtr<IObjectArray> poa;
hr = poc.QueryInterface(&poa);
if (SUCCEEDED(hr)) {
pcdl->AppendCategory((LPCTSTR)CString(MAKEINTRESOURCE(IDS_PROC_TASKS)), poa);
pcdl->CommitList();
}
}
示例4: CreateSeparatorLink
HRESULT CreateSeparatorLink(IShellLink **ppsl)
{
ATL::CComPtr<IPropertyStore> pps;
HRESULT hr = pps.CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER);
if (FAILED(hr))
return hr;
PROPVARIANT propvar;
hr = InitPropVariantFromBoolean(TRUE, &propvar);
if (FAILED(hr))
return hr;
hr = pps->SetValue(PKEY_AppUserModel_IsDestListSeparator, propvar);
if (SUCCEEDED(hr)) {
hr = pps->Commit();
if (SUCCEEDED(hr))
{
hr = pps.QueryInterface(ppsl);
}
}
PropVariantClear(&propvar);
return hr;
}