本文整理汇总了C++中CComSafeArray::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ CComSafeArray::Add方法的具体用法?C++ CComSafeArray::Add怎么用?C++ CComSafeArray::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComSafeArray
的用法示例。
在下文中一共展示了CComSafeArray::Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMouseUp
LRESULT IGToolCutterSquare::OnMouseUp (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
CComSafeArray <int> spSafeArrayPts;
spSafeArrayPts.Add (m_xPos1);
spSafeArrayPts.Add (m_yPos1);
m_xPos1 = GET_X_LPARAM(lParam);
m_yPos1 = GET_Y_LPARAM(lParam);
m_pFrame->ConvertCoordFrameToPixel ((LONG*)&m_xPos1, (LONG*)&m_yPos1);
spSafeArrayPts.Add (m_xPos1);
spSafeArrayPts.Add (m_yPos1);
CComVariant spVarArray (spSafeArrayPts);
int nTypeSelection = IGSELECTION_REPLACE;
if (::GetKeyState (VK_SHIFT) < 0)
nTypeSelection = IGSELECTION_ADD;
else if (::GetKeyState (VK_CONTROL) < 0)
nTypeSelection = IGSELECTION_REMOVE;
m_pFrame->ManageSelection (IGSELECTION_SQUARE | nTypeSelection, &spVarArray);
return 0L;
}
示例2:
CComSafeArray<BSTR> convertVector2CCOMSafeArray(Result x)
{
\
CComSafeArray<BSTR> result;
for (std::string inst : x)
{
result.Add(convertstdSTR2BSTR(inst));
}
return result;
}
示例3: explodeDn
STDMETHODIMP CLDAPQuery::explodeDn(
/* [in] */ BSTR str,
/* [in] */ ULONG notypes,
/* [retval][out] */ SAFEARRAY **result)
{
PTCHAR *vals = ldap_explode_dn(CComBSTR(str), notypes);
m_errorCode = LdapGetLastError();
if(vals)
{
CComSafeArray<VARIANT> dnValues;
for(LONG i = 0L; vals[i]!=NULL; i++)
{
dnValues.Add(CComVariant(vals[i]));
}
ldap_value_free(vals);
*result = dnValues.Detach();
}
return S_OK;
}
示例4: GetResults
STDMETHODIMP CTextSearch::GetResults(SAFEARRAY ** files)
{
// TODO: Add your implementation code here
Search searchService;
std::string path = searchService.ConvertBSTRToMBS(_searchPath);
//std::string keyword = searchService.ConvertBSTRToMBS(_searchKeyword);
std::vector<std::string> keywords;
for (int i = 0; i < (int)_searchKeywords.GetCount(); ++i)
keywords.push_back(searchService.ConvertBSTRToMBS(_searchKeywords[i].Copy()));
std::vector<std::string> results = searchService.StartTextSearch(keywords, path, _searchAll);
CComSafeArray<BSTR> temp;
for (auto result : results)
temp.Add(CComBSTR(result.c_str()));
*files = temp.Detach();
return S_OK;
}
示例5: XlLibraryInitialize
bool XlLibraryInitialize(XlAddInExportInfo* pExportInfo)
{
HRESULT hr;
CComPtr<ICorRuntimeHost> pHost;
hr = LoadClr20(&pHost);
if (FAILED(hr) || pHost == NULL)
{
// LoadClr20 shows diagnostic MessageBoxes if needed.
// Perhaps remember that we are not loaded?
return 0;
}
// If all is fine now, also start the CLR (always safe to do again.
hr = pHost->Start();
if (FAILED(hr))
{
ShowMessage(IDS_MSG_HEADER_NEEDCLR20,
IDS_MSG_BODY_HOSTSTART,
IDS_MSG_FOOTER_UNEXPECTED,
hr);
return 0;
}
CString addInFullPath = AddInFullPath();
CPath xllDirectory(addInFullPath);
xllDirectory.RemoveFileSpec();
CComPtr<IUnknown> pAppDomainSetupUnk;
hr = pHost->CreateDomainSetup(&pAppDomainSetupUnk);
if (FAILED(hr) || pAppDomainSetupUnk == NULL)
{
ShowMessage(IDS_MSG_HEADER_APPDOMAIN,
IDS_MSG_BODY_APPDOMAINSETUP,
IDS_MSG_FOOTER_UNEXPECTED,
hr);
return 0;
}
CComQIPtr<IAppDomainSetup> pAppDomainSetup = pAppDomainSetupUnk;
hr = pAppDomainSetup->put_ApplicationBase(CComBSTR(xllDirectory));
if (FAILED(hr))
{
ShowMessage(IDS_MSG_HEADER_APPDOMAIN,
IDS_MSG_BODY_APPLICATIONBASE,
IDS_MSG_FOOTER_UNEXPECTED,
hr);
return 0;
}
CComBSTR configFileName = addInFullPath;
configFileName.Append(L".config");
pAppDomainSetup->put_ConfigurationFile(configFileName);
CComBSTR appDomainName = L"ExcelDna: ";
appDomainName.Append(addInFullPath);
pAppDomainSetup->put_ApplicationName(appDomainName);
IUnknown *pAppDomainUnk = NULL;
hr = pHost->CreateDomainEx(appDomainName, pAppDomainSetupUnk, 0, &pAppDomainUnk);
if (FAILED(hr) || pAppDomainUnk == NULL)
{
ShowMessage(IDS_MSG_HEADER_APPDOMAIN,
IDS_MSG_BODY_APPDOMAIN,
IDS_MSG_FOOTER_UNEXPECTED,
hr);
return 0;
}
CComQIPtr<_AppDomain> pAppDomain(pAppDomainUnk);
// Load plan for ExcelDna.Loader:
// Try AppDomain.Load with the name ExcelDna.Loader.
// Then if it does not work, we will try to load from a known resource in the .xll.
CComPtr<_Assembly> pExcelDnaLoaderAssembly;
hr = pAppDomain->Load_2(CComBSTR(L"ExcelDna.Loader"), &pExcelDnaLoaderAssembly);
if (FAILED(hr) || pExcelDnaLoaderAssembly == NULL)
{
HRSRC hResInfoLoader = FindResource(hModuleCurrent, L"EXCELDNA_LOADER", L"ASSEMBLY");
if (hResInfoLoader == NULL)
{
ShowMessage(IDS_MSG_HEADER_APPDOMAIN,
IDS_MSG_BODY_MISSINGEXCELDNALOADER,
IDS_MSG_FOOTER_UNEXPECTED,
hr);
return 0;
}
HGLOBAL hLoader = LoadResource(hModuleCurrent, hResInfoLoader);
void* pLoader = LockResource(hLoader);
ULONG sizeLoader = (ULONG)SizeofResource(hModuleCurrent, hResInfoLoader);
CComSafeArray<BYTE> bytesLoader;
bytesLoader.Add(sizeLoader, (byte*)pLoader);
hr = pAppDomain->Load_3(bytesLoader, &pExcelDnaLoaderAssembly);
if (FAILED(hr))
{
//.........这里部分代码省略.........