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. BSTR from ATL DLL to Client

BSTR from ATL DLL to Client

Scheduled Pinned Locked Moved C / C++ / MFC
c++designbeta-testingquestioncode-review
3 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.
  • S Offline
    S Offline
    SiddharthAtw
    wrote on last edited by
    #1

    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.

    A A 2 Replies Last reply
    0
    • S SiddharthAtw

      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.

      A Offline
      A Offline
      Abhishek Srivastava
      wrote on last edited by
      #2

      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 :)

      1 Reply Last reply
      0
      • S SiddharthAtw

        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.

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

        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

        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