本文整理汇总了C++中CComBSTR::AppendBSTR方法的典型用法代码示例。如果您正苦于以下问题:C++ CComBSTR::AppendBSTR方法的具体用法?C++ CComBSTR::AppendBSTR怎么用?C++ CComBSTR::AppendBSTR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComBSTR
的用法示例。
在下文中一共展示了CComBSTR::AppendBSTR方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
STDMETHODIMP CUserObject::Init(BSTR host, BSTR location, BSTR account, BSTR *pErrorText)
{
wchar_t buf[1024];
HRESULT hr = S_FALSE;
GetTempPath(sizeof (buf) / sizeof (wchar_t), buf);
wcscat(buf, account);
wcscat(buf, L".log");
dlog.open(buf);
dlogi(L"Init", Log::KV<BSTR>(L"host", host), Log::KV<BSTR>(L"location", location),
Log::KV<BSTR>(L"account", account));
MailType = L"MAPI";
UserID = location;
if (host && *host)
{
hr = mapiObj->UserInit(location, account, pErrorText);
}
else
{
LPCWSTR err = MAPIAccessAPI::InitGlobalSessionAndStore(location);
if (err)
*pErrorText = CComBSTR(err);
else
hr = mapiObj->UserInit(L"", account, pErrorText);
}
if (FAILED(hr))
{
CComBSTR str = "Init error ";
str.AppendBSTR(*pErrorText);
dlog.err(str);
}
return hr;
}
示例2: SpeakText
STDMETHODIMP CAgentCtl::SpeakText(BSTR Text)
{
USES_CONVERSION;
TCHAR szText[256];
wsprintf(szText, _T("\\spd=%d\\"), m_nSpeed+100);
CComBSTR strText = szText;
strText.AppendBSTR(Text);
m_pCharacter->Show(FALSE, &m_nRequestID);
m_pCharacter->Speak((BSTR)strText, "", &m_nRequestID);
return S_OK;
}
示例3: GetValue
void CAttribute::GetValue( const LDAP_BERVAL * * pValue)
{
// Get value as a BERVAL. Must convert CComVariant into BERVAL if not valid
if( m_BERVAL_valid)
{
*pValue = &m_BERVAL;
return;
}
CComBSTR str;
switch( m_Value.vt) {
case VT_BSTR:
CHECKHR(str.AppendBSTR(m_Value.bstrVal));
m_BERVAL.bv_len = (str.Length() + 1) * sizeof(wchar_t);
m_BERVAL.bv_val = new char[m_BERVAL.bv_len];
memcpy( m_BERVAL.bv_val, str.m_str, (str.Length() * sizeof(wchar_t)) );
memset( &m_BERVAL.bv_val[str.Length() * sizeof(wchar_t)], 0, sizeof(wchar_t));
m_BERVAL_valid = true;
break;
case VT_DATE:
m_BERVAL.bv_len = sizeof(DATE);
m_BERVAL.bv_val = new char[m_BERVAL.bv_len];
*((DATE *)m_BERVAL.bv_val) = m_Value.date;
m_BERVAL_valid = true;
break;
case VT_EMPTY:
m_BERVAL.bv_len = 0;
m_BERVAL.bv_val = NULL;
m_BERVAL_valid = true;
break;
default:
CHECKTRUE(false);
break;
}
*pValue = &m_BERVAL;
}
示例4: WMIObjAddNVItem
long WMIUtil::WMIObjAddNVItem (IWbemClassObject * Obj, BSTR ObjAttr, NVDataItem * TargetData, char * DataName, char * DefaultVal)
{
USES_CONVERSION;
char NumBuf[NUM_BUF_SIZE];
CComVariant ValueVariant;
HRESULT hr;
hr = Obj->Get (ObjAttr, // Name
0, // Flags
&ValueVariant, // return Variant
NULL, NULL); // Type and Origin (optional parms)
if (FAILED(hr))
return ERROR_GEN_FAILURE;
//cout << "Partition VT = " << PartitionVariant.vt << endl;
switch (ValueVariant.vt) {
case VT_BSTR:
TargetData->AddNVItem (DataName, ValueVariant.bstrVal);
break;
case VT_I4:
TargetData->AddNVItem (DataName, _itoa(ValueVariant.lVal, NumBuf , 10));
break;
case VT_I2:
TargetData->AddNVItem (DataName, _itoa(ValueVariant.iVal, NumBuf , 10));
break;
case VT_BOOL:
TargetData->AddNVItem (DataName, ValueVariant.boolVal ? "Yes" : "No");
break;
// case VT_I8:
// TargetData->AddNVItem (DataName, _i64toa(ValueVariant.ullVal, NumBuf , 10));
// break;
case VT_R4:
TargetData->AddNVItem (DataName, _gcvt(ValueVariant.fltVal, 10, NumBuf));
break;
case VT_R8:
TargetData->AddNVItem (DataName, _gcvt(ValueVariant.dblVal, 10, NumBuf));
break;
case VT_I1:
TargetData->AddNVItem (DataName, _itoa(ValueVariant.bVal, NumBuf , 10));
break;
case VT_NULL:
case VT_EMPTY:
if (DefaultVal != NULL)
TargetData->AddNVItem (DataName, DefaultVal);
break;
case (VT_BSTR | VT_ARRAY):
{
if (ValueVariant.parray->cDims > 1)
return ERROR_GEN_FAILURE;
CComBSTR ConcatValue;
BSTR * BSTRAccess;
hr = SafeArrayAccessData (ValueVariant.parray, (void **) & BSTRAccess);
if (FAILED(hr))
return ERROR_GEN_FAILURE;
long Index;
long NumElements = ValueVariant.parray->rgsabound[0].cElements;
for (Index = 0; Index < NumElements; Index ++) {
if (Index > 0)
ConcatValue.Append(L",");
ConcatValue.AppendBSTR(BSTRAccess[Index]);
}
SafeArrayUnaccessData(ValueVariant.parray);
TargetData->AddNVItem (DataName, ConcatValue);
}
break;
case VT_I4 | VT_ARRAY:
case VT_I2 | VT_ARRAY:
default:
assert(0);
return ERROR_GEN_FAILURE;
}
return ERROR_SUCCESS;
//.........这里部分代码省略.........
示例5: GetProfilelist
STDMETHODIMP CMapiWrapper::GetProfilelist(VARIANT *Profiles,BSTR *statusmessage)
{
// TODO: Add your implementation code here
dlog.trace(L" Begin Mapiwrapper GetProfilelist");
HRESULT hr = S_OK;
CComBSTR status = L"";
hr = MAPIInitialize(NULL);
if( hr != S_OK)
{
LPCSTR temp = format_error(hr).c_str();
status.AppendBSTR(L" MapiInitialize error ");
status.AppendBSTR(A2BSTR(temp));
dlog.err(status);
*statusmessage = status;
return hr;
}
Zimbra::Mapi::Memory::SetMemAllocRoutines(NULL, MAPIAllocateBuffer, MAPIAllocateMore,
MAPIFreeBuffer);
vector<string> vProfileList;
hr = exchadmin->GetAllProfiles(vProfileList);
if( hr != S_OK)
{
LPCSTR temp = format_error(hr).c_str();
status.AppendBSTR(L" GetAllProfiles error ");
status.AppendBSTR(A2BSTR(temp));
dlog.err(status);
*statusmessage = status;
return hr;
}
if(vProfileList.size() == 0)
{
dlog.err(L"No profiles returned for GetAllProfiles");
status = L"No profiles";
*statusmessage = status;
status.Detach();
return S_OK;
}
vector<CComBSTR> tempvectors;
std::vector<string>::iterator its;
for (its = (vProfileList.begin()); its != vProfileList.end(); its++)
{
string str = (*its).c_str();
CComBSTR temp = SysAllocString(str_to_wstr(str).c_str());
tempvectors.push_back(temp);
}
VariantInit(Profiles);
Profiles->vt = VT_ARRAY | VT_BSTR;
SAFEARRAY *psa;
SAFEARRAYBOUND bounds = { (ULONG)vProfileList.size(), 0 };
psa = SafeArrayCreate(VT_BSTR, 1, &bounds);
BSTR *bstrArray;
SafeArrayAccessData(psa, (void **)&bstrArray);
std::vector<CComBSTR>::iterator it;
int i = 0;
for (it = (tempvectors.begin()); it != tempvectors.end(); it++, i++)
bstrArray[i] = SysAllocString((*it).m_str);
SafeArrayUnaccessData(psa);
Profiles->parray = psa;
*statusmessage = status;
status.Detach();
MAPIUninitialize();
dlog.trace(L" End Mapiwrapper GetProfilelist");
return hr;
}
示例6: OnBindGuid
//////////////////////////////////////////////////////
//
// GUID Binding: Only works with Active Directory
//
////////////////////////////////////////////////////////
void CDlgIADs::OnBindGuid()
{
CWaitCursor wait;
CComBSTR bstrPath;
IUnknown *pUnk = NULL;
HRESULT hr;
UpdateData(TRUE); // Retrieve from UI
CComPtr<IADsPathname> pPathname=NULL;
BSTR bstr;
BSTR bstrProvider;
BSTR bstrServer;
hr = CoCreateInstance( CLSID_Pathname, NULL, CLSCTX_INPROC_SERVER, IID_IADsPathname, (void**) &pPathname );
RETURN_ON_FAILURE(hr);
hr = m_pADs->get_ADsPath(&bstr);
RETURN_ON_FAILURE(hr);
/////////////////////////////////////////////////
// Usage: PathName to find out the provider
///////////////////////////////////////////////////
hr = pPathname->Set( bstr, ADS_SETTYPE_FULL );
SysFreeString( bstr );
RETURN_ON_FAILURE(hr);
hr = pPathname->Retrieve(ADS_FORMAT_PROVIDER, &bstrProvider );
RETURN_ON_FAILURE(hr);
if ( wcscmp( bstrProvider, L"LDAP") != 0 )
{
AfxMessageBox(_T("Only LDAP: (Active Directory Provider) knows about <GUID=xxxx> syntax"));
SysFreeString( bstrProvider );
return;
}
/////////////////////////////////////////////////
// Usage: PathName to find out the server
///////////////////////////////////////////////////
hr = pPathname->Retrieve(ADS_FORMAT_SERVER, &bstrServer );
if ( hr == E_ADS_BAD_PATHNAME ) // Serverless binding ( can work only from DS aware client )
{
bstrServer = SysAllocString(L"");
}
///////////////////////////////////////////////
// Now build the LDAP://server/<GUID=xxx
//////////////////////////////////////////////
bstrPath = bstrProvider;
bstrPath.Append(_T("://"));
if ( wcslen( bstrServer ) ) // Server based binding ?
{
bstrPath.AppendBSTR( bstrServer );
bstrPath.Append(_T("/"));
SysFreeString( bstrServer );
}
bstrPath.Append(_T("<GUID="));
bstrPath.Append( m_sGUID );
bstrPath.Append(_T(">") );
// we don't need these bstrs anymore
SysFreeString( bstrProvider );
// Now Bind using GUID
hr = App->ADsOpenObject( bstrPath, IID_IUnknown, (void**) &pUnk );
/////////////////////////////////////
// Bring up the IADs Dialog
///////////////////////////////////////
if ( SUCCEEDED(hr) )
{
pUnk->AddRef();
CDlgIADs dlg( pUnk, this );
dlg.DoModal();
pUnk->Release();
}
else
{
//.........这里部分代码省略.........