本文整理汇总了C++中atl::CComPtr::CoCreateInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ CComPtr::CoCreateInstance方法的具体用法?C++ CComPtr::CoCreateInstance怎么用?C++ CComPtr::CoCreateInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atl::CComPtr
的用法示例。
在下文中一共展示了CComPtr::CoCreateInstance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: openDoor
/**
* Opens the Door! :)
*
* Parameters:
* >szDoor
* Path to lock device for the door.
*
* Returns:
* N/A.
*/
void perco_exchange::openDoor(_In_ STLADD string_unique_ptr_t&& szDoor)
{
ATL::CComPtr<PERCo_S20_SDK::IExchangeMain> percoXchg;
if (SUCCEEDED(percoXchg.CoCreateInstance(__uuidof(PERCo_S20_SDK::CoExchangeMain))))
{
if (SUCCEEDED(percoXchg->SetConnect(PERCO_HOST, PERCO_PORT, PERCO_LOGIN, PERCO_PWD)))
{
BSTR szDBVersion;
BSTR szSDKVersion;
if (!percoXchg->CheckVersion(&szDBVersion, &szSDKVersion))
{
ATL::CComPtr<IXMLDOMDocument2> request = getSendCommandsRequest(std::move(szDoor));
AtlTrace2(ATL::atlTraceGeneral, 0, "Sending the 'sendcommands' request.\r\n");
if (request && SUCCEEDED(percoXchg->ExecuteCommand(request)))
{
AtlTrace2(ATL::atlTraceGeneral, 0, "PERCo has responded to the 'sendcommands' request.\r\n");
}
}
percoXchg->DisConnect();
}
}
else
{
AtlTrace2(ATL::atlTraceCOM, 0, "'PERCo_S20_SDK::IExchangeMain' ain't registered.\r\n");
}
}
示例2: 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);
}
}
示例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: hwnd
ProgressTaskBar(__RPC__in HWND hwnd, ULONGLONG Total)
: hwnd(hwnd)
, Total(Total)
{
if (FAILED(CoInitialize(nullptr)))
ATL::AtlThrowLastWin32();
if (FAILED(TaskbarList.CoCreateInstance(CLSID_TaskbarList)))
ATL::AtlThrowLastWin32();
}
示例5: 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);
}
}
示例6: 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;
}
示例7: 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;
}
示例8: new
ListViewAccServer * ListViewAccServer::CreateProvider(HWND hControl, ListViewAccProvider * provider)
{
ATL::CComPtr<IAccPropServices> pAccPropSvc;
HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
if (hr == S_OK && pAccPropSvc)
{
ListViewAccServer * pLVServer = new (std::nothrow) ListViewAccServer(pAccPropSvc);
if (pLVServer)
{
pLVServer->m_pAccProvider = provider;
MSAAPROPID propid = PROPID_ACC_HELP;
pAccPropSvc->SetHwndPropServer(hControl, (DWORD)OBJID_CLIENT, CHILDID_SELF, &propid, 1, pLVServer, ANNO_CONTAINER);
pLVServer->Release();
}
return pLVServer;
}
return NULL;
}
示例9: value
/**
* Create XML document to request 'staff' report from the 'PERCo_S20_SDK::IExchangeMain'.
*
* Parameters:
* None.
*
* Returns:
* XML document instance.
*/
ATL::CComPtr<IXMLDOMDocument2> perco_exchange::getStaffRequest() const
{
ATL::CComPtr<IXMLDOMDocument2> document;
if (SUCCEEDED(document.CoCreateInstance(CLSID_DOMDocument60, nullptr, CLSCTX_INPROC_SERVER)))
{
ATL::CComPtr<IXMLDOMProcessingInstruction> processingInstruction;
if (SUCCEEDED(document->createProcessingInstruction(
TEXT("xml"), TEXT("version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\""), &processingInstruction)))
{
document->appendChild(processingInstruction, nullptr);
// Create root <documentrequest> element.
ATL::CComPtr<IXMLDOMElement> documentRequest;
if (SUCCEEDED(document->createElement(TEXT("documentrequest"), &documentRequest)))
{
ATL::CComPtr<IXMLDOMAttribute> attribute;
if (SUCCEEDED(document->createAttribute(TEXT("type"), &attribute)))
{
ATL::CComVariant value(TEXT("staff"));
if (SUCCEEDED(attribute->put_value(value)) &&
SUCCEEDED(documentRequest->setAttributeNode(attribute, nullptr)))
{
attribute.Release();
if (SUCCEEDED(document->createAttribute(TEXT("mode_display"), &attribute)))
{
value = TEXT("employ_and_dismiss");
if (SUCCEEDED(attribute->put_value(value)) &&
SUCCEEDED(documentRequest->setAttributeNode(attribute, nullptr)))
{
if (FAILED(document->appendChild(documentRequest, nullptr)))
{
document.Release();
}
}
}
}
}
}
}
}
return document;
}
示例10: 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;
}
示例11: getIdentifiers
/**
* Gets identifiers map.
*
* Parameters:
* None.
*
* Returns:
* Identifiers map.
*/
perco_exchange::ids_t perco_exchange::getIdentifiers()
{
ids_t ids;
logger::const_ptr_t pLogger = logger::getInstance();
ATL::CComPtr<PERCo_S20_SDK::IExchangeMain> percoXchg;
if (SUCCEEDED(percoXchg.CoCreateInstance(__uuidof(PERCo_S20_SDK::CoExchangeMain))))
{
if (SUCCEEDED(percoXchg->SetConnect(PERCO_HOST, PERCO_PORT, PERCO_LOGIN, PERCO_PWD)))
{
BSTR szDBVersion;
BSTR szSDKVersion;
if (!percoXchg->CheckVersion(&szDBVersion, &szSDKVersion))
{
ATL::CComPtr<IXMLDOMDocument2> request = getStaffRequest();
#pragma region log
pLogger->logNotify(logger::CategoryGeneral, IDS_EVENT_STAFF_REQUEST_SEND);
AtlTrace2(ATL::atlTraceGeneral, 0, "Sending the 'staff' request.\r\n");
#pragma endregion log the message
if (request && SUCCEEDED(percoXchg->GetData(request)))
{
#pragma region log
pLogger->logNotify(logger::CategoryGeneral, IDS_EVENT_STAFF_REQUEST_HANDLED);
AtlTrace2(ATL::atlTraceGeneral, 0, "PERCo has responded to the 'staff' request.\r\n");
#pragma endregion log the message
ids = parseStaffResponse(request);
#pragma region log
CStringUtil::const_ptr_t pStringUtil = CStringUtil::getInstance();
LPTSTR pszFormat;
size_t nLength;
if (CStringUtil::ResourceSuccess ==
pStringUtil->loadString(IDS_EVENT_T_RESPOND_SIZE, &pszFormat, &nLength))
{
const STLADD regex_type regex(TEXT("(?:[^%]*)(?:%[[:digit:]]{0,2}u){1,1}(?:[^%]*)"));
if (std::regex_match(pszFormat, pszFormat + nLength, regex))
{
nLength += 15;
CMemoryManager::pointer_t pMemoryManager = CMemoryManager::getInstance();
LPTSTR pszText = pMemoryManager->mAllocChars<LPTSTR>(nLength);
if (pszText)
{
nLength = _stprintf_s(pszText, nLength, pszFormat, ids.size());
pLogger->log(logger::CategoryGeneral, logger::SeverityNotify, pszText, nLength);
pMemoryManager->free(pszText);
}
}
pStringUtil->freeString(pszFormat);
}
AtlTrace2(ATL::atlTraceGeneral, 0, "The respond parsed (%u entries handled).\r\n", ids.size());
#pragma endregion log the message
}
}
percoXchg->DisConnect();
}
}
else
{
#pragma region log
pLogger->logError(logger::CategoryCOM, IDS_EVENT_IEXCHANGEMAIN_AINT_REGISTERED);
AtlTrace2(ATL::atlTraceCOM, 0, "'PERCo_S20_SDK::IExchangeMain' ain't registered.\r\n");
#pragma endregion log the message
}
return ids;
}