Converting BSTR/CString to _bstr_t
-
The
_bstr_t
constructors accepts bothconst TCHAR *
andBSTR
, so it should be direct:CString strOne(_T("One"));
_bstr_t bstr(strOne); -
The
_bstr_t
constructors accepts bothconst TCHAR *
andBSTR
, so it should be direct:CString strOne(_T("One"));
_bstr_t bstr(strOne);I'm getting this error: error LNK2019: unresolved external symbol "void __cdecl _com_issue_error(long)" (?_com_issue_error@@YAXJ@Z) referenced in function "public: __thiscall _bstr_t::_bstr_t(unsigned short const *)" (??0_bstr_t@@QAE@PBG@Z) Any suggestions?
-
I'm getting this error: error LNK2019: unresolved external symbol "void __cdecl _com_issue_error(long)" (?_com_issue_error@@YAXJ@Z) referenced in function "public: __thiscall _bstr_t::_bstr_t(unsigned short const *)" (??0_bstr_t@@QAE@PBG@Z) Any suggestions?
Anonymous wrote: Any suggestions? Yes. You have to declare this function in order to trap COM errors. This function will only be declared once. You can use the following:
void __stdcall _com_issue_error(HRESULT m_hr)
{
TCHAR pcszError[1024];\_stprintf(pcszError, TEXT("\_com\_issue\_error(%ld)\\n"), m\_hr); OutputDebugString(pcszError);
}
-
I'd avoid _bstr_t altogether. Use ATL's CComBSTR. It's smaller.