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. General Programming
  3. COM
  4. Converting TCHAR to BSTR with ATL

Converting TCHAR to BSTR with ATL

Scheduled Pinned Locked Moved COM
c++helpquestion
6 Posts 4 Posters 3 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
    alma
    wrote on last edited by
    #1

    I have to convert a TCHAR string to BSTR in an ATL based service without using MFC. I tried T2OLE, but I could not compile the project because some errors: '_lpa' : undeclared identifier, ... Could anyone help me out? Alma

    V M M 3 Replies Last reply
    0
    • A alma

      I have to convert a TCHAR string to BSTR in an ATL based service without using MFC. I tried T2OLE, but I could not compile the project because some errors: '_lpa' : undeclared identifier, ... Could anyone help me out? Alma

      V Offline
      V Offline
      Vi2
      wrote on last edited by
      #2

      You can use CComBSTR class to make this conversion. CComBSTR bstrString( tcharString ); or bstrString = tcharOtherString; With best wishes, Vita

      A 1 Reply Last reply
      0
      • V Vi2

        You can use CComBSTR class to make this conversion. CComBSTR bstrString( tcharString ); or bstrString = tcharOtherString; With best wishes, Vita

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

        It worked, thanx

        1 Reply Last reply
        0
        • A alma

          I have to convert a TCHAR string to BSTR in an ATL based service without using MFC. I tried T2OLE, but I could not compile the project because some errors: '_lpa' : undeclared identifier, ... Could anyone help me out? Alma

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          The string conversion macros require that you put the USES_CONVERSION; macro at the beginning of the function/block. --Mike-- Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer My really out-of-date homepage Sonork-100.19012 Acid_Helm

          1 Reply Last reply
          0
          • A alma

            I have to convert a TCHAR string to BSTR in an ATL based service without using MFC. I tried T2OLE, but I could not compile the project because some errors: '_lpa' : undeclared identifier, ... Could anyone help me out? Alma

            M Offline
            M Offline
            Mark Janveaux
            wrote on last edited by
            #5

            Your getting this error because your not using the USES_CONVERSION macro in your functions that use the T2OLE macro. For example: void myfunc(LPTSTR szIN, BSTR* bszOut){ USES_CONVERSION; bszOut = T2OLE(szIN); } Hope that helps.

            A 1 Reply Last reply
            0
            • M Mark Janveaux

              Your getting this error because your not using the USES_CONVERSION macro in your functions that use the T2OLE macro. For example: void myfunc(LPTSTR szIN, BSTR* bszOut){ USES_CONVERSION; bszOut = T2OLE(szIN); } Hope that helps.

              A Offline
              A Offline
              alma
              wrote on last edited by
              #6

              Yep, it workes this way. Thanks.

              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