Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Converting BSTR/CString to _bstr_t

Converting BSTR/CString to _bstr_t

Scheduled Pinned Locked Moved Mobile
tutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Does anyone know how to convert BSTR/CString to _bstr_t

    J M 2 Replies Last reply
    0
    • A Anonymous

      Does anyone know how to convert BSTR/CString to _bstr_t

      J Offline
      J Offline
      Joao Paulo Figueira
      wrote on last edited by
      #2

      The _bstr_t constructors accepts both const TCHAR * and BSTR, so it should be direct:

      CString strOne(_T("One"));
      _bstr_t bstr(strOne);

      A 1 Reply Last reply
      0
      • J Joao Paulo Figueira

        The _bstr_t constructors accepts both const TCHAR * and BSTR, so it should be direct:

        CString strOne(_T("One"));
        _bstr_t bstr(strOne);

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        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?

        J 1 Reply Last reply
        0
        • A Anonymous

          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?

          J Offline
          J Offline
          Joao Paulo Figueira
          wrote on last edited by
          #4

          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);
          

          }

          1 Reply Last reply
          0
          • A Anonymous

            Does anyone know how to convert BSTR/CString to _bstr_t

            M Offline
            M Offline
            Mike Dimmick
            wrote on last edited by
            #5

            I'd avoid _bstr_t altogether. Use ATL's CComBSTR. It's smaller.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups