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. C / C++ / MFC
  4. how can i convert CComBSTR to char*

how can i convert CComBSTR to char*

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 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.
  • U Offline
    U Offline
    User 4429292
    wrote on last edited by
    #1

    hi please tell me good bye

    R 1 Reply Last reply
    0
    • U User 4429292

      hi please tell me good bye

      R Offline
      R Offline
      Robin Summerhill
      wrote on last edited by
      #2

      Take a look at the ATL string conversion macros. Try something like: USES_CONVERSION; CComBSTR bstrText(_T("String to convert")); TCHAR* asciiText = W2T(bstrText); Note that this uses TCHAR* instead of char* so that you can compile as unicode. Use W2A if you want to use ASCII explicitly. These functions allocate storage on the stack so don't try to access the converted string outside local scope - copy it if you want to return it from a function.

      J 1 Reply Last reply
      0
      • R Robin Summerhill

        Take a look at the ATL string conversion macros. Try something like: USES_CONVERSION; CComBSTR bstrText(_T("String to convert")); TCHAR* asciiText = W2T(bstrText); Note that this uses TCHAR* instead of char* so that you can compile as unicode. Use W2A if you want to use ASCII explicitly. These functions allocate storage on the stack so don't try to access the converted string outside local scope - copy it if you want to return it from a function.

        J Offline
        J Offline
        Jim
        wrote on last edited by
        #3

        bye~

        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