BSTR from ATL DLL to Client
-
I am using Win32SDK. What I want to do is to pass a BSTR from a ATL DLL to a Client? Now since Interface method can return only HRESULT. I will store the values in a Global Variable and use it in the client. Is there in Flaw on Design? I need feedback.
-
I am using Win32SDK. What I want to do is to pass a BSTR from a ATL DLL to a Client? Now since Interface method can return only HRESULT. I will store the values in a Global Variable and use it in the client. Is there in Flaw on Design? I need feedback.
you can use yourMethod([out,retval]BSTR **str); in VB u can use like this string str = yourMethod() Abhishek Srivastava Software Engineer (VC++) India ,Noida Mobile no 9891492921 :)
-
I am using Win32SDK. What I want to do is to pass a BSTR from a ATL DLL to a Client? Now since Interface method can return only HRESULT. I will store the values in a Global Variable and use it in the client. Is there in Flaw on Design? I need feedback.
The physical return value from an interface method is an HRESULT; however, you can also return a logical value if need be. For example in your coclass:
STDMETHODIMP InterfaceMethod1([out, retval]BSTR* pBSTR); STDMETHODIMP YourCoClass::InterfaceMethod1(BSTR* pBSTR) { *pBSTR = SysAllocString(OLESTR("Hello World!!")); return S_OK; }
Your client will need to call SysFreeString(BSTR bstr) when finished with the BSTR. JS