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. ATL / WTL / STL
  4. about parameter of BSTR

about parameter of BSTR

Scheduled Pinned Locked Moved ATL / WTL / STL
c++helpquestionlearning
8 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.
  • Y Offline
    Y Offline
    yingkou
    wrote on last edited by
    #1

    I am a beginer of learning programming by ATL ,I have writen a interface as below: HRESULT GetBSTR1([out,retval]BSTR* bstrInfo) { CComBSTR b(L"hello,you have called GetBSTR1"); *bstrInfo=b.Copy(); return S_OK; } HRESULT GetBSTR2([out]BSTR* bstrInfo) { CComBSTR b(L"hello,you have called GetBSTR2"); *bstrInfo=b.Copy(); return S_OK; } and VB Client Codes as below: Private Sub Command1_Click() Dim a As New ATLTESTLib.TestOne Dim str1, str2 As String str1 = a.GetBSTR1 MsgBox (str1) a.GetBSTR2(str2) MsgBox (str2) End Sub problem is str1 is OK,but str2 is empty,why?

    V 1 Reply Last reply
    0
    • Y yingkou

      I am a beginer of learning programming by ATL ,I have writen a interface as below: HRESULT GetBSTR1([out,retval]BSTR* bstrInfo) { CComBSTR b(L"hello,you have called GetBSTR1"); *bstrInfo=b.Copy(); return S_OK; } HRESULT GetBSTR2([out]BSTR* bstrInfo) { CComBSTR b(L"hello,you have called GetBSTR2"); *bstrInfo=b.Copy(); return S_OK; } and VB Client Codes as below: Private Sub Command1_Click() Dim a As New ATLTESTLib.TestOne Dim str1, str2 As String str1 = a.GetBSTR1 MsgBox (str1) a.GetBSTR2(str2) MsgBox (str2) End Sub problem is str1 is OK,but str2 is empty,why?

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

      CALL a.GetBSTR2(str2) or a.GetBSTR2 str2 With best wishes, Vita

      Y 1 Reply Last reply
      0
      • V Vi2

        CALL a.GetBSTR2(str2) or a.GetBSTR2 str2 With best wishes, Vita

        Y Offline
        Y Offline
        yingkou
        wrote on last edited by
        #3

        thanks a lot. a.GetBSTR2(str2) is error but a.GetBSTR2 str2 Is OK,why? could you tell me the reason?

        Y 1 Reply Last reply
        0
        • Y yingkou

          thanks a lot. a.GetBSTR2(str2) is error but a.GetBSTR2 str2 Is OK,why? could you tell me the reason?

          Y Offline
          Y Offline
          yingkou
          wrote on last edited by
          #4

          I also have a problem about BSTR Parameter,codes as below: HRESULT GetBSTR3([out]BSTR* bufName1,[out,retval]BSTR* bufName2) { USES_CONVERSION; CComBSTR b(L"hello,you have called GetBSTR3"); *bufName1=b.Copy(); TCHAR buf[]=TEXT("it is return value"); *bufName2=T2BSTR(buf); } VB Client as below: Private Sub Command1_Click() Dim a As New ATLTESTLib.TestOne Dim str1, str2 As String str2 = a.GetBSTR3(str1) MsgBox (str1) MsgBox (str2) End Sub running these codes, runtime error if I write codes as below: str2 = a.GetBSTR3 str1 compile error how can I do it?

          T V 2 Replies Last reply
          0
          • Y yingkou

            I also have a problem about BSTR Parameter,codes as below: HRESULT GetBSTR3([out]BSTR* bufName1,[out,retval]BSTR* bufName2) { USES_CONVERSION; CComBSTR b(L"hello,you have called GetBSTR3"); *bufName1=b.Copy(); TCHAR buf[]=TEXT("it is return value"); *bufName2=T2BSTR(buf); } VB Client as below: Private Sub Command1_Click() Dim a As New ATLTESTLib.TestOne Dim str1, str2 As String str2 = a.GetBSTR3(str1) MsgBox (str1) MsgBox (str2) End Sub running these codes, runtime error if I write codes as below: str2 = a.GetBSTR3 str1 compile error how can I do it?

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            Listen Borther Instead of using this yingkou wrote: str2 = a.GetBSTR3 str1 use this

            str2 = a.GetBSTR3(str1)


            "I Think this Will Help"  Alok Gupta
             visit me at http://www.thisisalok.tk

            Y 1 Reply Last reply
            0
            • T ThatsAlok

              Listen Borther Instead of using this yingkou wrote: str2 = a.GetBSTR3 str1 use this

              str2 = a.GetBSTR3(str1)


              "I Think this Will Help"  Alok Gupta
               visit me at http://www.thisisalok.tk

              Y Offline
              Y Offline
              yingkou
              wrote on last edited by
              #6

              str2 = a.GetBSTR3(str1) if I use this method, str1 and str2 are both empty. could you tell me the difference between a.GetBSTR2 str1 and a.GetBSTR2(str1)

              1 Reply Last reply
              0
              • Y yingkou

                I also have a problem about BSTR Parameter,codes as below: HRESULT GetBSTR3([out]BSTR* bufName1,[out,retval]BSTR* bufName2) { USES_CONVERSION; CComBSTR b(L"hello,you have called GetBSTR3"); *bufName1=b.Copy(); TCHAR buf[]=TEXT("it is return value"); *bufName2=T2BSTR(buf); } VB Client as below: Private Sub Command1_Click() Dim a As New ATLTESTLib.TestOne Dim str1, str2 As String str2 = a.GetBSTR3(str1) MsgBox (str1) MsgBox (str2) End Sub running these codes, runtime error if I write codes as below: str2 = a.GetBSTR3 str1 compile error how can I do it?

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

                Q: a.GetBSTR2(str2) is error but a.GetBSTR2 str2 Is OK,why? could you tell me the reason? A: This is a VB syntax requirement. Look at "Call Statement" in MSDN. Q: runtime error Dim str1, str2 As String str2 = a.GetBSTR3(str1) A: Variable "str1" is a Variant type here, because VB treats the Dim statement as: Dim str1 As Variant, str2 As String You should specify the type for each variable. With best wishes, Vita

                Y 1 Reply Last reply
                0
                • V Vi2

                  Q: a.GetBSTR2(str2) is error but a.GetBSTR2 str2 Is OK,why? could you tell me the reason? A: This is a VB syntax requirement. Look at "Call Statement" in MSDN. Q: runtime error Dim str1, str2 As String str2 = a.GetBSTR3(str1) A: Variable "str1" is a Variant type here, because VB treats the Dim statement as: Dim str1 As Variant, str2 As String You should specify the type for each variable. With best wishes, Vita

                  Y Offline
                  Y Offline
                  yingkou
                  wrote on last edited by
                  #8

                  I do it just like what you have said Dim str1 as String Dim str2 As String str2 = a.GetBSTR3(str1) but str1 and str2 are both empty

                  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