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 Connection Points: Problem to create an instance of an sink object.

COM Connection Points: Problem to create an instance of an sink object.

Scheduled Pinned Locked Moved COM
comhelpquestionc++sysadmin
3 Posts 2 Posters 5 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.
  • J Offline
    J Offline
    Juergen_80
    wrote on last edited by
    #1

    Hi All, I’m an absolutely newbie in the COM technology and I have a little tricky question. I hope there’s someone out there who can help me with my problem. I have an .idl / .h / .c file and I integrated them in my VisualStudio 2005 C++ project. After that I’ve searched on the MSDN Library how I can connect an COM Server from my project. I’ve found a little example (http://msdn.microsoft.com/en-us/magazine/cc163361.aspx) and tried to do it on the same way. I’ve created an Csink class and tried to create an instance of this sink object to pass to the server. But the problem now I get from my compiler is the following error message: „error C2259: 'CSink': cannot instantiate abstract class due to following members: 'HRESULT IUnknown::QueryInterface(const IID &,void **)' : is abstract“. The thing I need is that I must call the „ OnShowMessageDlg “ and the „ OnConfigurationApply “ functions out of the .idl file in my main c++ function. I’ve put all the code here below this entry that could help you to become an overview about my problem. Is the solution I’ve tried with the sink object correct or should I use another way to do this? Please let me know if you need any other information. Thanks for ANY help. ************************************************************************************************* .idl file . . . // TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046} importlib("stdole2.tlb"); // Forward declare all types defined in this typelib interface ITEST2; dispinterface ITESTEvents; . . . [ uuid(6775FB91-B5BE-11D6-A996-0050BA24C7B9), version(1.1), helpstring("Event dispatch interface for TEST") ] dispinterface ITESTEvents { properties: methods: [id(0x00000001)] void OnConfigurationApply([in, out] VARIANT_BOOL* pAccept); [id(0x00000002)] void OnShowMessageDlg( [in] IMsgDlg* pIMsg, [out, retval] VARIANT_BOOL* Result); }; . . . . coclass TESTv2 { [default] interface ITEST2; [default, source] dispinterface ITESTEvents; }; ************************************************************************************************* .h file . . . EXTERN_C const IID DIID_ITESTEvents; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("6775FB91-B5BE-11D6-A996-0050BA24C7B9") ITESTEvents : public IDispatch { }; #

    S 1 Reply Last reply
    0
    • J Juergen_80

      Hi All, I’m an absolutely newbie in the COM technology and I have a little tricky question. I hope there’s someone out there who can help me with my problem. I have an .idl / .h / .c file and I integrated them in my VisualStudio 2005 C++ project. After that I’ve searched on the MSDN Library how I can connect an COM Server from my project. I’ve found a little example (http://msdn.microsoft.com/en-us/magazine/cc163361.aspx) and tried to do it on the same way. I’ve created an Csink class and tried to create an instance of this sink object to pass to the server. But the problem now I get from my compiler is the following error message: „error C2259: 'CSink': cannot instantiate abstract class due to following members: 'HRESULT IUnknown::QueryInterface(const IID &,void **)' : is abstract“. The thing I need is that I must call the „ OnShowMessageDlg “ and the „ OnConfigurationApply “ functions out of the .idl file in my main c++ function. I’ve put all the code here below this entry that could help you to become an overview about my problem. Is the solution I’ve tried with the sink object correct or should I use another way to do this? Please let me know if you need any other information. Thanks for ANY help. ************************************************************************************************* .idl file . . . // TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046} importlib("stdole2.tlb"); // Forward declare all types defined in this typelib interface ITEST2; dispinterface ITESTEvents; . . . [ uuid(6775FB91-B5BE-11D6-A996-0050BA24C7B9), version(1.1), helpstring("Event dispatch interface for TEST") ] dispinterface ITESTEvents { properties: methods: [id(0x00000001)] void OnConfigurationApply([in, out] VARIANT_BOOL* pAccept); [id(0x00000002)] void OnShowMessageDlg( [in] IMsgDlg* pIMsg, [out, retval] VARIANT_BOOL* Result); }; . . . . coclass TESTv2 { [default] interface ITEST2; [default, source] dispinterface ITESTEvents; }; ************************************************************************************************* .h file . . . EXTERN_C const IID DIID_ITESTEvents; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("6775FB91-B5BE-11D6-A996-0050BA24C7B9") ITESTEvents : public IDispatch { }; #

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      You need to implement the methods of the interfaces that ITESTEvents inherits from - that's going to be IDispatch, which in turn inherits from IUnknown. That's a fair bit of work... There are a couple of CodeProject articles that might be of use: here[^] and here[^].

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      J 1 Reply Last reply
      0
      • S Stuart Dootson

        You need to implement the methods of the interfaces that ITESTEvents inherits from - that's going to be IDispatch, which in turn inherits from IUnknown. That's a fair bit of work... There are a couple of CodeProject articles that might be of use: here[^] and here[^].

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        J Offline
        J Offline
        Juergen_80
        wrote on last edited by
        #3

        Thanks for your reply. I think, now the next step can be done.

        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