本文整理汇总了C++中CComBSTR类的典型用法代码示例。如果您正苦于以下问题:C++ CComBSTR类的具体用法?C++ CComBSTR怎么用?C++ CComBSTR使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CComBSTR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
HRESULT CTypeInfoBrowse::CrackExtendProperty(ICxEnumExtendProperty* pEnum, CPropInfoArray& arrProp)
{
LONG nIndex;
HRESULT hr;
CPropInfo prop;
pEnum->Reset();
while (S_FALSE != pEnum->Next(&nIndex))
{
hr = pEnum->GetType((LONG *)&prop.m_proptype);
if (FAILED(hr))
return hr;
CComBSTR bstr;
hr = pEnum->GetName(&bstr);
if (FAILED(hr))
return hr;
prop.m_bstrName = bstr;
bstr.Empty();
hr = pEnum->GetDescription(&bstr);
if (FAILED(hr))
return hr;
prop.m_bstrDesc = bstr;
hr = pEnum->GetDispid(&prop.m_dispid);
if (FAILED(hr))
return hr;
arrProp.Add(prop);
}
return S_OK;
}
示例2: ASSERT
BOOL vmsMetalinkFile::ReadHashNode(IXMLDOMNode *pNode, vmsMetalinkFile_File_Hash *hash)
{
USES_CONVERSION;
IXMLDOMNamedNodeMapPtr spAttrs;
pNode->get_attributes (&spAttrs);
if (spAttrs == NULL)
return FALSE;
IXMLDOMNodePtr spType;
spAttrs->getNamedItem (L"type", &spType);
if (spType == NULL)
return FALSE;
COleVariant vt;
spType->get_nodeValue (&vt);
ASSERT (vt.vt == VT_BSTR);
if (vt.vt == VT_BSTR)
hash->strAlgorithm = W2A (vt.bstrVal);
CComBSTR bstrText;
pNode->get_text (&bstrText);
if (bstrText.Length () == 0)
return FALSE;
hash->strChecksum = W2A (bstrText);
return TRUE;
}
示例3: EncodeStrokeToXML
void CStrokeRecognition::EncodeStrokeToXML(std::vector<BasicStroke> &rgStrokes, BSTR* StrokeResult)
{
CComBSTR strokeXML;
char szTmp[1024];
strokeXML = "<?xml version=\"1.0\"?><output><strokes candidatenum=\"1\">";
sprintf(szTmp, "<candidate similarity=\"1\" strokenum=\"%d\">", rgStrokes.size());
strokeXML += szTmp;
for (unsigned int i = 0; i < rgStrokes.size(); i++)
{
switch (rgStrokes[i].iStrokeType)
{
case PRIMITIVE_SEGMENT:
{
sprintf(szTmp, "<line><startpt x=\"%d\" y=\"%d\"/><endpt x=\"%d\" y=\"%d\"/></line>",
rgStrokes[i].segment.startPoint.x, rgStrokes[i].segment.startPoint.y,
rgStrokes[i].segment.endPoint.x, rgStrokes[i].segment.endPoint.y);
strokeXML += szTmp;
}
break;
case PRIMITIVE_ARC:
{
double x1, y1, x2, y2;
double cx, cy, a, b;
cx = (rgStrokes[i].arc.rcBounding.left + rgStrokes[i].arc.rcBounding.right) / 2;
cy = (rgStrokes[i].arc.rcBounding.top + rgStrokes[i].arc.rcBounding.bottom) / 2;
a = (rgStrokes[i].arc.rcBounding.right - rgStrokes[i].arc.rcBounding.left) / 2;
b = (rgStrokes[i].arc.rcBounding.bottom - rgStrokes[i].arc.rcBounding.top) / 2;
CalcEllipsePointByAngle(cx, cy, a, b, 0, ConvertToEllipseAngle(rgStrokes[i].arc.startAngle, a, b), x1, y1);
CalcEllipsePointByAngle(cx, cy, a, b, 0, ConvertToEllipseAngle(rgStrokes[i].arc.endAngle, a, b), x2, y2);
if (rgStrokes[i].arc.endAngle - rgStrokes[i].arc.startAngle >= 1.9 * PI)
{
sprintf(szTmp, "<arc rotate=\"%f\"><startpt x=\"%d\" y=\"%d\"/><endpt x=\"%d\" y=\"%d\"/><ltpt x=\"%d\" y=\"%d\"/><rbpt x=\"%d\" y=\"%d\"/></arc>",
(float)(rgStrokes[i].arc.rotateAngle),
(int)x1, (int)y1, (int)x1, (int)y1,
rgStrokes[i].arc.rcBounding.left, rgStrokes[i].arc.rcBounding.top,
rgStrokes[i].arc.rcBounding.right, rgStrokes[i].arc.rcBounding.bottom);
}
else
{
sprintf(szTmp, "<arc rotate=\"%f\"><startpt x=\"%d\" y=\"%d\"/><endpt x=\"%d\" y=\"%d\"/><ltpt x=\"%d\" y=\"%d\"/><rbpt x=\"%d\" y=\"%d\"/></arc>",
(float)(rgStrokes[i].arc.rotateAngle),
(int)x1, (int)y1, (int)x2, (int)y2,
rgStrokes[i].arc.rcBounding.left, rgStrokes[i].arc.rcBounding.top,
rgStrokes[i].arc.rcBounding.right, rgStrokes[i].arc.rcBounding.bottom);
}
strokeXML += szTmp;
}
break;
}
}
strokeXML += "</candidate></strokes></output>";
strokeXML.CopyTo(StrokeResult);
}
示例4: DateTime_Evaluate
//extern "C" {
HRESULT WINAPI DateTime_Evaluate( DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings, char *pResult, size_t maxlen, DWORD reserved )
{
DATE Time;
DWORDLONG address = GetAddress( pHelper, dwAddress);
if( !ReadMem( pHelper, address, &Time) )
return E_FAIL;
if(Time == 0.)
{
strcpy(pResult, "zero");
return S_OK;
}
if(Time == ( 65535. * 2147483647. ) || Time == (2147483647.))
{
strcpy(pResult, "invalid");
return S_OK;
}
if(Time == ( 65535. * 2147483648. ) || Time == (2147483648.))
{
strcpy(pResult, "null");
return S_OK;
}
CComBSTR strDate ;
HRESULT hr = VarBstrFromDate(Time, LOCALE_USER_DEFAULT, 0, &strDate);
if (FAILED(hr)) return hr;
if(strDate != 0)
WideCharToMultiByte(CP_ACP, 0, strDate, strDate.Length(), pResult, maxlen , NULL, NULL);
return S_OK;
}
示例5: LOWORD
LRESULT CShellViewImpl::OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
WORD wMenuID = LOWORD(wParam);
WORD wFlags = HIWORD(wParam);
// If the selected menu item is one of ours, show a flyby help string
// in the Explorer status bar.
if ( !(wFlags & MF_POPUP) )
{
switch ( wMenuID )
{
case IDC_EXPLORE_DRIVE:
case IDC_SYS_PROPERTIES:
case IDC_ABOUT_SIMPLENS:
{
CComBSTR bsHelpText;
if ( bsHelpText.LoadString ( wMenuID ))
{
m_spShellBrowser->SetStatusTextSB ( bsHelpText.m_str );
}
return 0;
}
break;
}
}
// Otherwise, pass the message to the default handler.
return DefWindowProc();
}
示例6: SaveWhiteboardSettingsData
/****************************************
** Author: Joe Li
** Purpose: Save whiteboard settings data
** Comments:
****************************************/
bool DOSaveAppData::SaveWhiteboardSettingsData(const CComBSTR& sourcePath, const CComBSTR& targetPath)
{
if (sourcePath.Length() != 0 && targetPath.Length() != 0)
{
const unsigned long bufferSize = 256;
TCHAR buffer[bufferSize];
DOPersistentFile sourceFile;
// Search for first source file
if (sourceFile.FindFirstFile(sourcePath, WHITEBOARD_SETTINGS_WILDCARD_SEARCH, buffer, bufferSize) == true)
{
CComBSTR sourceFileName = buffer;
bool allWhiteboardSettingsSaved = SaveWhiteboardSettings(sourcePath, sourceFileName, targetPath);
// Search of remaining source file(s)
while (sourceFile.FindNextFile(buffer, bufferSize) == true)
{
sourceFileName = buffer;
allWhiteboardSettingsSaved = SaveWhiteboardSettings(sourcePath, sourceFileName, targetPath) && allWhiteboardSettingsSaved;
}
return allWhiteboardSettingsSaved;
}
}
return false;
}
示例7: SetValueAsString
HRESULT Property::SetValueAsString(
LPCOLESTR pszValue,
DWORD dwRadix,
DWORD dwTimeout )
{
// even though it could be read only, let's parse and eval, so we get good errors
HRESULT hr = S_OK;
CComBSTR assignExprText = mFullExprText;
CComBSTR errStr;
UINT errPos;
CComPtr<IDebugExpression2> expr;
CComPtr<IDebugProperty2> prop;
if ( assignExprText == NULL )
return E_OUTOFMEMORY;
hr = assignExprText.Append( L" = " );
if ( FAILED( hr ) )
return hr;
hr = assignExprText.Append( pszValue );
if ( FAILED( hr ) )
return hr;
hr = mExprContext->ParseText( assignExprText, 0, dwRadix, &expr, &errStr, &errPos );
if ( FAILED( hr ) )
return hr;
hr = expr->EvaluateSync( 0, dwTimeout, NULL, &prop );
if ( FAILED( hr ) )
return hr;
return S_OK;
}
示例8: StringFromXML
bool Skein::BoolFromXML(IXMLDOMNode* node, LPWSTR query, bool ifNon)
{
CComBSTR text = StringFromXML(node,query);
if (text.Length() > 0)
return wcscmp(text.m_str,L"YES") == 0;
return ifNon;
}
示例9: pt
char * CCoordTransService::CoordTransToStringEx (
double dX, double dY, bool isX, char *pBuffer, int iLen)
{
if (m_fIsInitialized) {
try {
CComBSTR bstr;
CCSPoint pt (dX, dY);
if (isX) {
THROW_FAILED_HRESULT(m_CTF -> ToStrings (&pt, &bstr, NULL, NULL));
} else {
THROW_FAILED_HRESULT(m_CTF -> ToStrings (&pt, NULL, &bstr, NULL));
}
USES_CONVERSION;
iLen = min(bstr.Length(), iLen-1);
strncpy (pBuffer, OLE2A(bstr), iLen);
pBuffer[iLen] = '\0';
return pBuffer;
} catch (_com_error &e) {
ShowError (_COM_ERROR(e), IDS_CSSERRORCAPTION, g_cbCoordTransToStringEx);
return NULL;
}
}
ShowError (TRIAS02_E_CSSNOTINITIALIZED, IDS_CSSERRORCAPTION, g_cbCoordTransToStringEx);
return NULL;
}
示例10: NodeExistsInParent
BOOL NodeExistsInParent(CComPtr<ItcProjectNode> owner_node, CComBSTR name) {
_ASSERT( owner_node != NULL );
if ((name.Length() > 0) && FAILED(name.ToLower()))
return FALSE;
CComPtr<ItcProjectNodeIterator> iterator;
if (FAILED( owner_node->CreateChildIterator(&iterator) )) {
return FALSE;
}
while (iterator->HasNext() == VARIANT_TRUE) {
CComPtr <ItcProjectNode> node;
if (FAILED( iterator->Next(&node) )) {
return FALSE;
}
CComBSTR caption;
if (SUCCEEDED( node->get_Caption(&caption) )) {
if ((caption.Length() == 0) || SUCCEEDED(caption.ToLower())) {
if (caption == name) {
return TRUE;
}
}
}
}
return FALSE;
}
示例11: A2W
STDMETHODIMP CJoystickCtl::getProductName(BSTR *pName) {
USES_CONVERSION;
char* name = stick.getProductName();
CComBSTR wName = A2W(name);
*pName = wName.Detach();
return S_OK;
}
示例12: while
/////////////////////////////////////////////////////////////////////
// OPCBrowser::Item method
// Item index is 1-based for VB
STDMETHODIMP COPCBrowserImpl::Item( VARIANT ItemSpecifier, BSTR *pItem)
{
if( ItemSpecifier.vt != VT_I4 && ItemSpecifier.vt != VT_I2 )
return E_INVALIDARG;
if( ItemSpecifier.vt == VT_I2 )
ItemSpecifier.lVal = ItemSpecifier.iVal;
if( ItemSpecifier.lVal < 1 || ItemSpecifier.lVal > m_names.size() )
return E_INVALIDARG;
if( pItem == NULL )
return E_INVALIDARG;
LONG index=1;
m_listPosition = m_names.begin();
while( m_listPosition!=m_names.end() && index < ItemSpecifier.lVal )
{
m_listPosition++;
index++;
}
if( index == ItemSpecifier.lVal )
{
CComBSTR* pName = *m_listPosition;
*pItem = pName->Copy();
return S_OK;
}
return E_FAIL;
}
示例13: GetFilter_new
HRESULT GetFilter_new(dimension_t dimension, short index, BSTR* filter)
{
std::string szFG;
std::string szFV;
int newIndex = offset_to_new_index_(atFilter,dimension, index);
XXGetFilterEx_(dimension, newIndex, &szFG, &szFV);
CComBSTR bFilter;
// ff::ignore_missing_arguments_scope scoper;
// fastformat::fmt(bFilter, "{0}{1}{2}{3}", szFG, winstl::w2m(strFilterSeparator), szFV);
#if 0
fastformat::write(bFilter, szFG, winstl::w2m(strFilterSeparator), szFV); // +1
*filter = bFilter.Detach();
#else /* ? 0 */
# if 1
*filter = fastformat::write(bFilter, szFG, winstl::w2m(strFilterSeparator), szFV).Detach(); // +1
# else /* ? 0 */
// This should not work, but does with some compilers ...
*filter = fastformat::write(CComBSTR(), szFG, winstl::w2m(strFilterSeparator), szFV).Detach(); // +1
# endif /* 0 */
#endif /* 0 */
return S_OK;
}
示例14: UacRestoreVolumeHeader
extern "C" int UacRestoreVolumeHeader (HWND hwndDlg, wchar_t *lpszVolume)
{
CComPtr<ITrueCryptMainCom> tc;
int r;
CoInitialize (NULL);
if (ComGetInstance (hwndDlg, &tc))
{
CComBSTR volumeBstr;
BSTR bstr = W2BSTR(lpszVolume);
if (bstr)
{
volumeBstr.Attach (bstr);
r = tc->RestoreVolumeHeader ((LONG_PTR) hwndDlg, volumeBstr);
}
else
r = ERR_OUTOFMEMORY;
}
else
r = -1;
CoUninitialize ();
return r;
}
示例15: get_Fields
STDMETHODIMP CSimplePointDatasetHelper::FetchAll(long ClassIndex, BSTR WhereClause, VARIANT FieldMap, IPlugInCursorHelper **cursorHelper)
{
HRESULT hr;
if (! cursorHelper) return E_POINTER;
// Some parameters can be ignored since,
// ClassIndex is only relevant to feature datasets
// WhereClause is not appropriate since we are not supporting SQL
ISimplePointCursorHelperPtr ipSimplePointCursorHelper;
hr = ipSimplePointCursorHelper.CreateInstance(CLSID_SimplePointCursorHelper);
if (FAILED(hr)) return hr;
hr = ipSimplePointCursorHelper->put_FieldMap(FieldMap);
if (FAILED(hr)) return hr;
IFieldsPtr ipFields;
hr = get_Fields(0, &ipFields);
if (FAILED(hr)) return hr;
hr = ipSimplePointCursorHelper->putref_Fields(ipFields);
if (FAILED(hr)) return hr;
CComBSTR sFilePath;
sFilePath = m_sWorkspacePath;
sFilePath.Append(m_sDatasetName);
hr = ipSimplePointCursorHelper->put_FilePath(sFilePath);
if (FAILED(hr)) return hr;
IPlugInCursorHelperPtr ipPlugInCursorHelper;
ipPlugInCursorHelper = ipSimplePointCursorHelper;
if (ipPlugInCursorHelper == NULL) return E_FAIL;
*cursorHelper = ipPlugInCursorHelper.Detach(); // Pass ownership of object back to client
return S_OK;
}