当前位置: 首页>>代码示例>>C++>>正文


C++ _bstr_t类代码示例

本文整理汇总了C++中_bstr_t的典型用法代码示例。如果您正苦于以下问题:C++ _bstr_t类的具体用法?C++ _bstr_t怎么用?C++ _bstr_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了_bstr_t类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MessageBox

//查询时间段内有效的流行线
_RecordsetPtr CFloatRowLine::QueryValidateLines(_bstr_t bstrBeginDate,_bstr_t bstrEndDate)
{
	if (bstrBeginDate.length()<=0||bstrEndDate.length()<=0)
	{
		MessageBox(NULL,_T("请输入有效时间间隔!"),_T("提示"),0);
		return FALSE;
	}

	if (!theBllApp.m_bConntSuccess)
	{
		MessageBox(NULL,_T("数据库连接失败!"),_T("提示"),0);
		return FALSE;
	}
	if (!theBllApp.m_pDB->CheckTableNameExist("流行线"))
	{
		MessageBox(NULL,_T("数据库中不存在该流行线业务表!"),_T("提示"),0);
		return FALSE;
	}
	_bstr_t bstrSql;
	switch(CDatabaseFactory::m_enumDatabaseType)
	{
	case AccessType:
		bstrSql="select 流行线.编号,名称,所属目标,启用时间,结束时间  from 流行线,流行线属性   where  流行线.编号=流行线属性.所属流行线 and (启用时间<=#"+bstrBeginDate+"# and  结束时间>=#"+bstrBeginDate+"#) or(启用时间>=#"+bstrBeginDate+"# and  结束时间<=#"+bstrEndDate+"#)  or(启用时间<=#"+bstrEndDate+"# and  结束时间>=#"+bstrEndDate+"#)  order by 流行线.编号";
		break;
	case SqlServerType:
		bstrSql="select  流行线.编号,名称,所属目标,启用时间,结束时间  from 流行线,流行线属性  where 流行线.编号=流行线属性.所属流行线 and (启用时间<='"+bstrBeginDate+"' and  结束时间>='"+bstrBeginDate+"') or(启用时间>='"+bstrBeginDate+"' and  结束时间<='"+bstrEndDate+"')  or(启用时间<='"+bstrEndDate+"' and  结束时间>='"+bstrEndDate+"')  order by 流行线.编号";
		break;
	case OracleType:
		bstrSql="select  流行线.编号,名称,所属目标,启用时间,结束时间  from 流行线,流行线属性  where 流行线.编号=流行线属性.所属流行线 and (启用时间<=to_date('" + bstrBeginDate + "','dd/mm/yyyy') and  结束时间>=to_date('" + bstrBeginDate + "','dd/mm/yyyy')) or(启用时间>=to_date('" + bstrBeginDate + "','dd/mm/yyyy') and  结束时间<=to_date('" + bstrEndDate + "','dd/mm/yyyy'))  or(启用时间<=to_date('" + bstrEndDate + "','dd/mm/yyyy') and  结束时间>=to_date('" + bstrEndDate + "','dd/mm/yyyy'))  order by 流行线.编号";
		break;
	default:
		return FALSE;
	}
	return theBllApp.m_pDB->ExcuteSqlRes(bstrSql,adCmdText);
}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:36,代码来源:FloatRowLine.cpp

示例2: MessageBox

//检查重点目标名称更新
BOOL CEmphasesTarget::NameValidate(_bstr_t bstrName,_bstr_t bstrID)
{
	if (bstrName.length()<=0 || bstrID.length()<=0)
	{
		MessageBox(NULL,_T("请选择要加载重点目标!"),_T("提示"),0);
		return FALSE;
	}
	if (!theBllApp.m_bConntSuccess)
	{
		MessageBox(NULL,_T("数据库连接失败!"),_T("提示"),0);
		return FALSE;
	}
	if (!theBllApp.m_pDB->CheckTableNameExist("重点目标"))
	{
		MessageBox(NULL,_T("数据库中不存在该重点目标业务表!"),_T("提示"),0);
		return FALSE;
	}
	_RecordsetPtr pRecordSet;
	_bstr_t strSQL;
	strSQL = "SELECT 编号,名称,类型,所属区域,地址,坐标,描述 FROM 重点目标 WHERE 编号<>"+bstrID+" and  名称 = '" + bstrName+"'";
	pRecordSet = theBllApp.m_pDB->ExcuteSqlRes(strSQL,adCmdText);
	if (pRecordSet!=NULL && !pRecordSet->adoEOF)
		return FALSE;
	pRecordSet->Close();
	pRecordSet.Release();
	return TRUE;
}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:28,代码来源:EmphasesTarget.cpp

示例3: _bstr_cmp

long _bstr_cmp(const _bstr_t& cmp1, const _bstr_t& cmp2)
{
	long nRes = 0;

	if (cmp1.length() && cmp2.length())
	{
		nRes = wcscmp(cmp1, cmp2);
	}
	else if (cmp1.length() == 0)
	{
		if (cmp2.length() == 0)
		{
			nRes = 0;
		}
		else
		{
			nRes = -1;
		}
	}
	else
	{
		nRes = 1;
	}

	return nRes;
}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:26,代码来源:stdafx.cpp

示例4: data

STDMETHODIMP CPluginImpl::get_XMLInfo( BSTR *pVal )
{
    try {
        if ( !pVal )
            return E_POINTER;
        *pVal = 0;

        static const _bstr_t data(
            OLESTR("<grym_plugin_info>")
            OLESTR("<name>Export</name>")
            OLESTR("<description>Blip-blop! Version") PLUGIN_VER_STR OLESTR("</description>")
            OLESTR("<copyright>gureedo, 2012, Freeware</copyright>")
            OLESTR("<tag>EXPORtPLUGIN</tag>")
            OLESTR("<supported_languages>")
            OLESTR("<language>*</language>")
            OLESTR("</supported_languages>")
            OLESTR("<requirements>")
            OLESTR("<requirement_api>API-1.4</requirement_api>")
            OLESTR("</requirements>")
            OLESTR("</grym_plugin_info>")
        );

        *pVal = data.copy();

        return S_OK;
    } catch(...) {
    }

    return E_FAIL;
}
开发者ID:jimdi,项目名称:2gis-export-plugin,代码行数:30,代码来源:PluginImpl.cpp

示例5: if

HRESULT CTCPropBagOnRegKey::_GetObjectCLSID(const _bstr_t& strName,
  CLSID& clsid, CRegKey& subkey, _bstr_t& strObjectID, IErrorLog* pErrorLog)
{
  USES_CONVERSION;

  // Clear the specified clsid, subkey, and strObjectID parameters
  clsid = CLSID_NULL;
  subkey.Close();
  strObjectID.Empty();

  // Open the subkey with the specified name
  if (!strName.length())
    subkey = m_key;
  else if (!m_key.Exists(strName) || !subkey.Open(m_key, strName))
    return HRESULT_FROM_WIN32(GetLastError());

  // Use local resources for string loading
  MCLibRes res;

  // Read the object's CLSID string value
  HRESULT hr;
  _bstr_t strDesc;
  if (subkey.GetString(m_szCLSID, strObjectID))
  {
    // Convert the object's CLSID string to a CLSID
    LPOLESTR pszObjectID = const_cast<LPOLESTR>(T2COLE(strObjectID));
    hr = CLSIDFromString(pszObjectID, &clsid);
    if (SUCCEEDED(hr))
      return hr;

    // Format an error description string   
    strDesc.Format(IDS_FMT_FAIL_CONVERT_CLSID, strObjectID);
  }
  else if (subkey.GetString(m_szProgID, strObjectID))
  {
    // Convert the object's ProgID string to a CLSID
    hr = CLSIDFromProgID(T2COLE(strObjectID), &clsid);
    if (SUCCEEDED(hr))
      return hr;

    // Format an error description string
    strDesc.Format(IDS_FMT_FAIL_CONVERT_CLSID, strObjectID);
  }
  else
  {
    // Save the last error
    hr = HRESULT_FROM_WIN32(GetLastError());

    // Format an error description string
    strDesc.LoadString(IDS_FAIL_READ_CLSID);
  }

  // Log the error and return
  return LogError("GetObjectCLSID", strDesc, hr, T2COLE(strName), pErrorLog);
}
开发者ID:AllegianceZone,项目名称:Allegiance,代码行数:55,代码来源:TCPropBagOnRegKey.cpp

示例6: HandleOpenByFileName

void CDocument::HandleOpenByFileName(const CStdString& sDocumentFileName, const _bstr_t& openPassword, const _bstr_t& modifyPassword, const _bstr_t& unrestrictPassword)
{
	LOG_WS_FUNCTION_SCOPE();
	if(!PathFileExists(sDocumentFileName.c_str()))
		throw Workshare::System::IO::FileNotFoundException(sDocumentFileName, _T("The document could not be opened because it doesn't exist or has an invalid name."));

	WSFileFormat::IFileTypeCheckerPtr spFileTypeChecker;
	HRESULT hr = spFileTypeChecker.CreateInstance(_T("WSFileFormat.FileTypeChecker"));
	if (FAILED(hr))
	{
		if (REGDB_E_CLASSNOTREG == hr)
		{
			throw Workshare::ClassNotFoundException(_T("WSFileFormat.FileTypeChecker"), _T("Failed to create an instance of CFileTypeChecker when opening document by filename."));
		}
		throw Workshare::Com::ComException(_T("Failed to create an instance of CFileTypeChecker when opening document by filename."), hr);
	}

	IMWApplication* pApplication = 0;
	hr = m_pApplication->QueryInterface(__uuidof(IMWApplication), reinterpret_cast<void**>(&pApplication));
	if(FAILED(hr))
		throw Workshare::Com::ComException(_T("Failed to query an IMWApplication instance from the internal application object"), hr, m_pApplication);
	IMWApplicationPtr spApplication(pApplication, false);

	int fileType = spFileTypeChecker->GetFileType(sDocumentFileName.c_str());
	if(WSFileFormat::wsFileTypeWord == fileType)
	{
		if (FF_MS_WORD_6 >= spFileTypeChecker->GetFileFormat(sDocumentFileName.c_str()))
			throw Workshare::FileFormatVersionNotSupportedException(sDocumentFileName.c_str(), _T("MS Word"), _T("Word 6.0/95"), _T("Encountered a word document version lower than or equal to Word95/6.0"));
	}

	SetCorrectDocumentType(fileType, sDocumentFileName.c_str(), spApplication);
	//then we need to figure out what supported elements based on file type to pass down...

	IMWMetadataElements* pSupportedElements = 0;
	hr = m_pDocumentType->get_SupportedElements(&pSupportedElements);
	if(FAILED(hr))
		throw Workshare::Com::ComException(_T("Failed to obtain the file type's supported elements when opening document by filename."), hr, m_pDocumentType);

	IMWMetadataElementsPtr spSupportedElements(pSupportedElements, false);
	MetadataElementsConverter converter;
	//we know the IMWMetadataElements are the same creature, but the converter uses the Metawall namespace and this project does #import "WPAPI.tlb" no_namespace 
	Workshare::Protect::MetadataElements supportedElements = converter.ConvertComElements(reinterpret_cast<Metawall::IMWMetadataElements*>(spSupportedElements.GetInterfacePtr()));

	SetupImplementorsWithSupportedElements(fileType, supportedElements, sDocumentFileName.c_str());

	if(m_spImplementor.get() == 0)
		throw Workshare::OutOfMemoryException(_T("Failed to initialize the implementor"));

	m_spImplementor->SetFileFormat(spFileTypeChecker->GetFileType(sDocumentFileName.c_str()));

	if(openPassword.length() > 0 || modifyPassword.length() > 0 || unrestrictPassword.length() > 0)
		m_spImplementor->Open(sDocumentFileName, static_cast<const wchar_t*>(openPassword), static_cast<const wchar_t*>(modifyPassword), static_cast<const wchar_t*>(unrestrictPassword));
	else
		m_spImplementor->Open(sDocumentFileName);
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:55,代码来源:Document.cpp

示例7: _LoadObject

HRESULT CTCPropBagOnRegKey::_LoadObject(const _bstr_t& strName,
  IUnknown* punkObj, IErrorLog* pErrorLog)
{
  // Validate the specified parameters
  if (IsBadReadPtr(punkObj))
    return E_POINTER;
  if (NULL != pErrorLog && IsBadReadPtr(pErrorLog))
    return E_POINTER;

  // Open the subkey with the specified name
  CRegKey subkey;
  if (!strName.length())
    subkey = m_key;
  else if (!m_key.Exists(strName) || !subkey.Open(m_key, strName))
    return HRESULT_FROM_WIN32(GetLastError());

  // QueryInterface for IPersistPropertyBag
  IPersistPropertyBagPtr pppb;
  HRESULT hr = punkObj->QueryInterface(__uuidof(pppb), (void**)&pppb);
  if (FAILED(hr))
    return hr;

  // Load the object's persistent properties
  CComObjectStack<CTCPropBagOnRegKey> bag;
  bag.Init(subkey, strName, this);
  hr = pppb->Load(&bag, pErrorLog);

  // Return the last HRESULT
  return hr;
}
开发者ID:AllegianceZone,项目名称:Allegiance,代码行数:30,代码来源:TCPropBagOnRegKey.cpp

示例8: GetPropertyItemValues

HRESULT CCOMDispatchHelper::GetPropertyItemValues(const IDispatchPtr& pICollection, int iIndex, 
												  _bstr_t& bstrName, _bstr_t& bstrValue)
{
	HRESULT hr = E_FAIL;
	variant_t result, vIndex;
	vIndex.lVal = iIndex;
	vIndex.vt = VT_I4;
	hr = AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &result, pICollection, L"Item", 1, vIndex);
	RETURN_FAILED(hr);

	IDispatchPtr spPropItem = result.pdispVal;

	variant_t vPropItem;

	hr = AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &vPropItem, spPropItem, L"Name", 0);
	RETURN_FAILED(hr);

	bstrName.Assign(vPropItem.bstrVal);

	hr = AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &vPropItem, spPropItem, L"Value", 0);
	RETURN_FAILED(hr);

	//ComConvertUtils aComConvertUtils;

	//TODO look at a better way of casting a variant_t to a PROPVARIANT
	bstrValue = (LPCTSTR)PropVariantToString(*(PROPVARIANT*)(VARIANT*)&vPropItem);

	return hr;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:29,代码来源:COMDispatchHelper.cpp

示例9: LoadXml

bool CXmlDocument::LoadXml(const _bstr_t &xmlString)
{
	if ( m_pDoc ==NULL )
		Initialize();

	ATLASSERT(m_pDoc!=NULL);

	if(xmlString.length() == 0) return false;

	if(m_pDoc->_loadXML(xmlString))
	{
		m_szUrl.Empty();
		m_pNode = GetRoot();
		//set default selection namespaces
		CString cstr = GetNameSpaces();
		if(!cstr.IsEmpty())
		{
			m_pDoc->_setProperty(_T("SelectionNamespaces"), (LPCTSTR)cstr);
		}
		return true;
	}
	else
	{
		m_szUrl.Empty();
		m_pNode = NULL;
		return false;
	}
}
开发者ID:firememory,项目名称:BuddyDesk,代码行数:28,代码来源:Util_XMLDOM.cpp

示例10: CompareBSTRNoCase

//比较两个BSTR类型的字符串(忽略大小写)
int CompareBSTRNoCase(_bstr_t bstr1, _bstr_t bstr2)
{
	CComBSTR comBstr1(bstr1.GetBSTR());
	CComBSTR comBstr2(bstr2.GetBSTR());

	comBstr1.ToLower();
	comBstr2.ToLower();

	if (comBstr1 == comBstr2)
		return 0;
	else if (comBstr1 > comBstr2)
		return 1;
	else
		return -1;

}
开发者ID:vizcount,项目名称:work,代码行数:17,代码来源:CommFunc.cpp

示例11: _SaveObject

HRESULT CTCPropBagOnRegKey::_SaveObject(const _bstr_t& strName,
  IUnknown* punkObj, BOOL bClearDirty, BOOL bSaveAllProperties)
{
  // Validate the specified parameters
  if (IsBadReadPtr(punkObj))
    return E_POINTER;

  // Create a subkey with the specified name
  CRegKey subkey;
  if (!strName.length())
    subkey = m_key;
  else
  {
    m_key.DeleteValue(strName);
    m_key.RecurseDeleteKey(strName);
    if (!subkey.Open(m_key, strName))
      return HRESULT_FROM_WIN32(GetLastError());
  }

  // QueryInterface for IPersistPropertyBag
  IPersistPropertyBagPtr pppb;
  HRESULT hr = punkObj->QueryInterface(__uuidof(pppb), (void**)&pppb);
  if (FAILED(hr))
    return hr;

  // Get the object's CLSID
  CLSID clsid;
  hr = pppb->GetClassID(&clsid);
  if (FAILED(hr))
    return hr;

  // Attempt first to convert the object's CLSID to a ProgID
  LPOLESTR pszProgID = NULL;
  if (SUCCEEDED(ProgIDFromCLSID(clsid, &pszProgID)))
  {
    subkey.WriteString(m_szProgID, pszProgID);
    CoTaskMemFree(pszProgID);
  }
  else
  {
    // Convert the object's CLSID to a string
    OLECHAR szClassID[64];
    StringFromGUID2(clsid, szClassID, sizeofArray(szClassID));
    subkey.WriteString(m_szCLSID, szClassID);
  }

  // Write the variant type value
  subkey.WriteDWord(m_szVariantType, DWORD(VarTypeFromUnknown(punkObj)));

  // Save the persistent properties of the object
  CComObjectStack<CTCPropBagOnRegKey> bag;
  bag.Init(subkey, strName, this);
  hr = pppb->Save(&bag, bClearDirty, bSaveAllProperties);

  // Return the last HRESULT
  return hr;
}
开发者ID:AllegianceZone,项目名称:Allegiance,代码行数:57,代码来源:TCPropBagOnRegKey.cpp

示例12: GetOle32Lib

HRESULT CTCPropBagOnRegKey::_CreateRemoteObject(const _bstr_t& strServer,
  const _bstr_t& strName, IUnknown** ppunkObj, IErrorLog* pErrorLog)
{
  // If DCOM is not installed, take appropriate action
  MCOle32_dll& libOle32 = GetOle32Lib();
  if (!libOle32.Exists_CoCreateInstanceEx())
    return !strServer.length() ?
      CreateLocalObject(strName, ppunkObj, pErrorLog) : E_UNEXPECTED;

  // Read the CLSID of the object saved on the specified subkey
  CLSID clsid;
  CRegKey subkey;
  _bstr_t strObjectID;
  HRESULT hr = GetObjectCLSID(strName, clsid, subkey, strObjectID,
    pErrorLog);
  if (FAILED(hr))
    return hr;

  // Create the object
  USES_CONVERSION;
  _bstr_t bstrServer(strServer);
  COSERVERINFO csi = {0, bstrServer, NULL, 0};
  MULTI_QI mqi = {&IID_IPersistPropertyBag, NULL, 0};
  DWORD dwCtx = CLSCTX_ALL | CLSCTX_REMOTE_SERVER;
  hr = libOle32.CoCreateInstanceEx(clsid, NULL, dwCtx, &csi, 1, &mqi);
  if (FAILED(hr))
  {
    // Use local resources
    MCLibRes res;

    // Format a description string
    _bstr_t strDesc;
    strDesc.Format(IDS_FMT_FAIL_CREATE_CLSID, strObjectID);

    // Log the error
    USES_CONVERSION;
    return LogError("CreateObject", strDesc, hr, T2COLE(strName), pErrorLog);
  }

  // Attach the interface pointer to the smart pointer
  IPersistPropertyBagPtr pppb((IPersistPropertyBag*)mqi.pItf, false);
  
  // Load the object's persistent properties
  CComObjectStack<CTCPropBagOnRegKey> bag;
  bag.Init(subkey, strName, this);
  hr = pppb->Load(&bag, pErrorLog);
  if (FAILED(hr))
    return hr;

  // Detach the IUnknown* and copy to the [out] parameter, don't Release it
  *ppunkObj = pppb.Detach();

  // Indicate success
  return S_OK;
}
开发者ID:AllegianceZone,项目名称:Allegiance,代码行数:55,代码来源:TCPropBagOnRegKey.cpp

示例13: Loadproperties

void CFloatRowLine::Loadproperties(_bstr_t bstrID, std::vector<string> &vecField, std::vector<string> &vecRecordSet, long &lFieldCounts)
{
	if (bstrID.length()<=0)
	{
		MessageBox(NULL,_T("请选择要加载属性的流行线!"),_T("提示"),0);
		return;
	}
	_RecordsetPtr res = Loadproperties(bstrID);
	if(res==NULL)
		return;

	CBllHelp::Instance().QueryByCondit(res,vecField,vecRecordSet,lFieldCounts);
}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:13,代码来源:FloatRowLine.cpp

示例14: catch

Xml::Status::code Xml::Document::load (_bstr_t xmlDocumentFilename)
{
    // see if there's an existing...
    if (this->x_xmlDocument)
    {
        // delete the existing...
        delete static_cast<ShellDocument *>(this->x_xmlDocument);
        this->x_xmlDocument = 0;
    }
    if (xmlDocumentFilename.length () > 0)
    {
        // create a new dom shell...
        if (this->x_xmlDocument = new ShellDocument ())
        {
            // load the document...
            if (static_cast<ShellDocument *>(this->x_xmlDocument)->domDocument)
            {
                IXMLDOMNode *newDomNode;
                // load the file or stream...
                try
                {
                    if (((wchar_t *)xmlDocumentFilename)[0] == '<')
                    {
                        newDomNode = static_cast<ShellDocument *>(this->x_xmlDocument)->loadXML (xmlDocumentFilename);
                    }
                    else
                    {
                        newDomNode = static_cast<ShellDocument *>(this->x_xmlDocument)->loadFile (xmlDocumentFilename);
                    }
                }
                catch (...)
                {
                    // failed...
                }
                // validate the node...
                if (newDomNode)
                {
                    // copy to the root node...
                    if (DOMInterfaceCollections::copyNode (&this->rootNode,newDomNode))
                    {
                        // return success...
                        return static_cast<ShellDocument *>(this->x_xmlDocument)->status = Xml::Status::ready;
                    }
                }
                // failing load...
                return static_cast<ShellDocument *>(this->x_xmlDocument)->status = Xml::Status::invalidDocument;
            }
        }
    }
    return static_cast<ShellDocument *>(this->x_xmlDocument)->status = Xml::Status::failed;
}
开发者ID:DigitalTouchSoft,项目名称:XmlHelper,代码行数:51,代码来源:Document.cpp

示例15: _SetServer

HRESULT CTCPropBagOnRegKey::_SetServer(const _bstr_t& strName,
  const _bstr_t& strServer)
{
  // Open the subkey with the specified name
  CRegKey subkey;
  if (!strName.length())
    subkey = m_key;
  else if (!m_key.Exists(strName) || !subkey.Open(m_key, strName))
    return HRESULT_FROM_WIN32(GetLastError());

  // Write the Server of the object saved on the specified subkey
  subkey.WriteString(m_szServer, strServer);

  // Indicate success
  return S_OK;
}
开发者ID:AllegianceZone,项目名称:Allegiance,代码行数:16,代码来源:TCPropBagOnRegKey.cpp


注:本文中的_bstr_t类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。