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. Unbelievable error when attempting to return a BSTR** as retval

Unbelievable error when attempting to return a BSTR** as retval

Scheduled Pinned Locked Moved C / C++ / MFC
comhelptutorialquestion
10 Posts 5 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.
  • N Offline
    N Offline
    Nish Nishant
    wrote on last edited by
    #1

    interface INishFirst : IDispatch { [id(1), helpstring("method GetString")] HRESULT GetString([in] BSTR* pbstrInString, [out,retval] BSTR* pbstrOutString); [id(2), helpstring("method GetArray")] HRESULT GetArray([out,retval] BSTR** pbstrArray); }; It's showing an error :- warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'pbstrArray' of Procedure 'GetArray' ( Interface 'INishFirst' ) ] Am I not allowed to have BSTR **s???? My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org

    D F T M 5 Replies Last reply
    0
    • N Nish Nishant

      interface INishFirst : IDispatch { [id(1), helpstring("method GetString")] HRESULT GetString([in] BSTR* pbstrInString, [out,retval] BSTR* pbstrOutString); [id(2), helpstring("method GetArray")] HRESULT GetArray([out,retval] BSTR** pbstrArray); }; It's showing an error :- warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'pbstrArray' of Procedure 'GetArray' ( Interface 'INishFirst' ) ] Am I not allowed to have BSTR **s???? My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org

      D Offline
      D Offline
      Derek Waters
      wrote on last edited by
      #2

      You can have BSTR **, so long as you don't want your COM object to be Automation-compatible (ie usable in ASP). The Automation type standard is quite strict on this sort of thing. ------------------------ Derek Waters derek@lj-oz.com

      N 1 Reply Last reply
      0
      • N Nish Nishant

        interface INishFirst : IDispatch { [id(1), helpstring("method GetString")] HRESULT GetString([in] BSTR* pbstrInString, [out,retval] BSTR* pbstrOutString); [id(2), helpstring("method GetArray")] HRESULT GetArray([out,retval] BSTR** pbstrArray); }; It's showing an error :- warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'pbstrArray' of Procedure 'GetArray' ( Interface 'INishFirst' ) ] Am I not allowed to have BSTR **s???? My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org

        F Offline
        F Offline
        Felix Cho
        wrote on last edited by
        #3

        BSTR is already a pointer. So BSTR** is a "triple pointer" (omg! :confused: ), which of course is not supported by automation. From MSDN: typedef OLECHAR FAR* BSTR;

        1 Reply Last reply
        0
        • N Nish Nishant

          interface INishFirst : IDispatch { [id(1), helpstring("method GetString")] HRESULT GetString([in] BSTR* pbstrInString, [out,retval] BSTR* pbstrOutString); [id(2), helpstring("method GetArray")] HRESULT GetArray([out,retval] BSTR** pbstrArray); }; It's showing an error :- warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'pbstrArray' of Procedure 'GetArray' ( Interface 'INishFirst' ) ] Am I not allowed to have BSTR **s???? My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org

          F Offline
          F Offline
          Felix Cho
          wrote on last edited by
          #4

          I might want to add: - use BSTR for your [in] param - use BSTR* for your [out] param Edit: fixed the little bug in my 2nd statement ;-P

          N 1 Reply Last reply
          0
          • F Felix Cho

            I might want to add: - use BSTR for your [in] param - use BSTR* for your [out] param Edit: fixed the little bug in my 2nd statement ;-P

            N Offline
            N Offline
            Nish Nishant
            wrote on last edited by
            #5

            Felix Cho wrote: use BSTR for your [out] param Huh? I was just advised to use BSTR* as my out parameters Nish My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org

            F 1 Reply Last reply
            0
            • D Derek Waters

              You can have BSTR **, so long as you don't want your COM object to be Automation-compatible (ie usable in ASP). The Automation type standard is quite strict on this sort of thing. ------------------------ Derek Waters derek@lj-oz.com

              N Offline
              N Offline
              Nish Nishant
              wrote on last edited by
              #6

              Derek Waters wrote: You can have BSTR **, so long as you don't want your COM object to be Automation-compatible (ie usable in ASP). The Automation type standard is quite strict on this sort of thing. Thanks again Derek. I jus found that out :-( Nish My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org

              1 Reply Last reply
              0
              • N Nish Nishant

                interface INishFirst : IDispatch { [id(1), helpstring("method GetString")] HRESULT GetString([in] BSTR* pbstrInString, [out,retval] BSTR* pbstrOutString); [id(2), helpstring("method GetArray")] HRESULT GetArray([out,retval] BSTR** pbstrArray); }; It's showing an error :- warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'pbstrArray' of Procedure 'GetArray' ( Interface 'INishFirst' ) ] Am I not allowed to have BSTR **s???? My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org

                T Offline
                T Offline
                Tim Smith
                wrote on last edited by
                #7

                Just some more information... The OLE Automation restriction is there for a reason. The idea is that if an interface supports OLE automation no external proxy code is required to marshal the calls. I leave it to the reader to translated what I just said into English. I know for the longest time I had NO CLUE what any of that ment. (Heh, and I hope I got the statement right.) Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?

                N 1 Reply Last reply
                0
                • T Tim Smith

                  Just some more information... The OLE Automation restriction is there for a reason. The idea is that if an interface supports OLE automation no external proxy code is required to marshal the calls. I leave it to the reader to translated what I just said into English. I know for the longest time I had NO CLUE what any of that ment. (Heh, and I hope I got the statement right.) Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?

                  N Offline
                  N Offline
                  Nish Nishant
                  wrote on last edited by
                  #8

                  Thanks Tim. Nish My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org

                  1 Reply Last reply
                  0
                  • N Nish Nishant

                    Felix Cho wrote: use BSTR for your [out] param Huh? I was just advised to use BSTR* as my out parameters Nish My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org

                    F Offline
                    F Offline
                    Felix Cho
                    wrote on last edited by
                    #9

                    Nish [BusterBoy] wrote: I was just advised to use BSTR* as my out parameters I meant to say that actually, must be smoking crack... Sorry for the confusion ;-P

                    1 Reply Last reply
                    0
                    • N Nish Nishant

                      interface INishFirst : IDispatch { [id(1), helpstring("method GetString")] HRESULT GetString([in] BSTR* pbstrInString, [out,retval] BSTR* pbstrOutString); [id(2), helpstring("method GetArray")] HRESULT GetArray([out,retval] BSTR** pbstrArray); }; It's showing an error :- warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'pbstrArray' of Procedure 'GetArray' ( Interface 'INishFirst' ) ] Am I not allowed to have BSTR **s???? My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org

                      M Offline
                      M Offline
                      Mazdak
                      wrote on last edited by
                      #10

                      Nish,It's also nice to use _bstr_t,it encapsulate the BSTR data type.It manages resource allocation and deallocation through internall calls to SysAllocString() and SysFreeeStrnig so you don't have to add these function to your code.It provides a number of operators that enable you to use a _bstr_t object as easily as you would use a CString.But one thing that isn't provide,is the & "address of" operator,so can't pass the address of a _bstr_t to a function that expects a BSTR *. Hope that helps. Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
                      Wish You Were Here-Pink Floyd-1975

                      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