Unbelievable error when attempting to return a BSTR** as retval
-
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
-
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
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
-
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
-
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
-
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
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
-
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
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
-
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
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?
-
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?
Thanks Tim. Nish My most recent CP article :- A newbie's elementary guide to spawning processes www.busterboy.org
-
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
-
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
Nish,It's also nice to use
_bstr_t
,it encapsulate theBSTR
data type.It manages resource allocation and deallocation through internall calls toSysAllocString()
andSysFreeeStrnig
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 aCString
.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 aBSTR *
. 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