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. COM
  4. COM Interface -> C++ wrapper utility ?

COM Interface -> C++ wrapper utility ?

Scheduled Pinned Locked Moved COM
c++comtoolsquestion
4 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.
  • V Offline
    V Offline
    vipsy
    wrote on last edited by
    #1

    Hi all, I want to find an utility that do something like that: Takes TLB (or whatever) and generates C++ wrapper classes for use these COM interfaces/objects. With ATL it could looking like: IDL: interface ITest { HRESULT GetName([out,retval] BSTR *bstrName); HRESULT DoSmth([in] BSTR str); } C++ (ATL) Wrapper: class CTest : public CComPtr { public: CString getName() { CComBSTR bstr; HRESULT hr = p->GetName(&bstr); if (FAILED(hr)) throw hr; return CString(bstr); } HRESULT doSmth(LPCTSTR str) { return p->DoSmth(CComBSTR(str)); } } Such wrappers allows to program COM in C++ much easier, almost like in VB, at the same time preserving all C++ power. Does anyone knows something similar ? Thanks in advance, vips

    I 1 Reply Last reply
    0
    • V vipsy

      Hi all, I want to find an utility that do something like that: Takes TLB (or whatever) and generates C++ wrapper classes for use these COM interfaces/objects. With ATL it could looking like: IDL: interface ITest { HRESULT GetName([out,retval] BSTR *bstrName); HRESULT DoSmth([in] BSTR str); } C++ (ATL) Wrapper: class CTest : public CComPtr { public: CString getName() { CComBSTR bstr; HRESULT hr = p->GetName(&bstr); if (FAILED(hr)) throw hr; return CString(bstr); } HRESULT doSmth(LPCTSTR str) { return p->DoSmth(CComBSTR(str)); } } Such wrappers allows to program COM in C++ much easier, almost like in VB, at the same time preserving all C++ power. Does anyone knows something similar ? Thanks in advance, vips

      I Offline
      I Offline
      ian mariano
      wrote on last edited by
      #2

      The #import directive already does this for you automatically.

      Ian Mariano - http://www.ian-space.com/
      "We are all wave equations in the information matrix of the universe" - me

      V 1 Reply Last reply
      0
      • I ian mariano

        The #import directive already does this for you automatically.

        Ian Mariano - http://www.ian-space.com/
        "We are all wave equations in the information matrix of the universe" - me

        V Offline
        V Offline
        vipsy
        wrote on last edited by
        #3

        Thank you for fast reply. I'll try to discover the #import behavoir in C++.

        L 1 Reply Last reply
        0
        • V vipsy

          Thank you for fast reply. I'll try to discover the #import behavoir in C++.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          you can also use MIDL /h file.h to get an IDL file you can use oleview

          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