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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. BSTR to const char[]

BSTR to const char[]

Scheduled Pinned Locked Moved ATL / WTL / STL
comdata-structurestoolshelpquestion
7 Posts 4 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
    AssemblySoft
    wrote on last edited by
    #1

    I've created a get / put property inside an activeX control. I know the functionality is working ok because i've tested it with script What i now need to do is copy the BSTR into a char* or c style array. I've tried: char str[MAX_PATH]; CComBSTR m_bstrString; put: ATLTRACE(_T("String assigned to: %ls\n"),newVal); m_bstrFileString = newVal; //assign btr to CComBSTR //do conversion BSTR var = m_bstrString.Copy(); strcat(str,(LPCTSTR)var); It only seems to be copying the first char? Please help :doh:

    A M 2 Replies Last reply
    0
    • A AssemblySoft

      I've created a get / put property inside an activeX control. I know the functionality is working ok because i've tested it with script What i now need to do is copy the BSTR into a char* or c style array. I've tried: char str[MAX_PATH]; CComBSTR m_bstrString; put: ATLTRACE(_T("String assigned to: %ls\n"),newVal); m_bstrFileString = newVal; //assign btr to CComBSTR //do conversion BSTR var = m_bstrString.Copy(); strcat(str,(LPCTSTR)var); It only seems to be copying the first char? Please help :doh:

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

      I'm sure this will help: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_atl_String_Conversion_Macros.asp[^]

      S A 2 Replies Last reply
      0
      • A Anonymous

        I'm sure this will help: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_atl_String_Conversion_Macros.asp[^]

        S Offline
        S Offline
        SandeepN
        wrote on last edited by
        #3

        The following line has undefined variable m_bstrFileString (could be typo) m_bstrFileString = newVal; //assign btr to CComBSTR Note : W2A macros has limitation, can not be used in loop. It can convert max 500KB of chars One more soln would be using _bstr_t class.. For Ex: char str[MAX_PATH]; _bstr_t str1(newVal); strcpy(str,(char *)str1); Sandeep Naik

        A 1 Reply Last reply
        0
        • A AssemblySoft

          I've created a get / put property inside an activeX control. I know the functionality is working ok because i've tested it with script What i now need to do is copy the BSTR into a char* or c style array. I've tried: char str[MAX_PATH]; CComBSTR m_bstrString; put: ATLTRACE(_T("String assigned to: %ls\n"),newVal); m_bstrFileString = newVal; //assign btr to CComBSTR //do conversion BSTR var = m_bstrString.Copy(); strcat(str,(LPCTSTR)var); It only seems to be copying the first char? Please help :doh:

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

          See The Complete Guide to C++ Strings, Part II - String Wrapper Classes[^] --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Laugh it up, fuzzball. "Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer."   -- Michael P. Butler in the Lounge

          A 1 Reply Last reply
          0
          • A Anonymous

            I'm sure this will help: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_atl_String_Conversion_Macros.asp[^]

            A Offline
            A Offline
            AssemblySoft
            wrote on last edited by
            #5

            thanks i will try that. Could you please have a look at my thread 'ATL activeX control Initialize', directly below this one.

            1 Reply Last reply
            0
            • S SandeepN

              The following line has undefined variable m_bstrFileString (could be typo) m_bstrFileString = newVal; //assign btr to CComBSTR Note : W2A macros has limitation, can not be used in loop. It can convert max 500KB of chars One more soln would be using _bstr_t class.. For Ex: char str[MAX_PATH]; _bstr_t str1(newVal); strcpy(str,(char *)str1); Sandeep Naik

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

              thanks i will try that. Could you please have a look at my thread 'ATL activeX control Initialize', directly below this one.

              1 Reply Last reply
              0
              • M Michael Dunn

                See The Complete Guide to C++ Strings, Part II - String Wrapper Classes[^] --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Laugh it up, fuzzball. "Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer."   -- Michael P. Butler in the Lounge

                A Offline
                A Offline
                AssemblySoft
                wrote on last edited by
                #7

                thanks i will try that. Could you please have a look at my thread 'ATL activeX control Initialize', directly below this one.

                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