• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 578
  • Last Modified:

How to create object that will receive connection notifications??

In MSDN I read:

"The IDccMan interface is implemented by the Windows CE connection manager. It allows an application some control of the connection manager and the ability to register for connection notifications. An application creates this interface by calling the COM CoCreateInstance function using the CLSID_DccMan GUID, and receiving a pointer to an IDccMan interface."

OK I can create this interface BUT....

The IDccMan::Advise method is called by a client application to register an IDccManSink object for receiving connection notifications from the Windows CE connection manager.

HRESULT STDMETHODIMP IDccMan::Advise(IDccManSink * pDccSink, DWORD pdwContext);

Pointer to an IDccManSink object that will receive connection notifications.
Pointer to a DWORD that will receive a context value used by the IDccMan object to identify the IDccManSink object that was passed in. The value pointed to by pdwContext should be passed in the call to IDccMan::Unadvise.

I would like to know how to create IDccManSink object that will receive connection notifications....???????

Code please...

Thank you very much for your help...

1 Solution
It is simple: just create C++ class and inhirit it from  IDccManSink
for example:
class CMySinkObject : public  IDccManSink
    ~CMySinkObject(); // note not virtual!
// IUnknown methods:
    ULONG AddRef(void);
    HRESULT QueryInterface( REFIID iid, void ** ppvObject);
    ULONG Release(void);
// IDccManSink methods;
   STDMETHODIMP OnLogAnswered(void);
   STDMETHODIMP OnLogActive(void);
   STDMETHODIMP OnLogDisconnection(void);
   STDMETHODIMP OnLogError(void);
   STDMETHODIMP OnLogInactive(void);
   STDMETHODIMP OnLogListen(void);
   STDMETHODIMP OnLogTerminated(void);
   DWORD m_dwRefCount;

implementation for iUnknow ios trivial:
ULONG CMySinkObject::AddRef(void)
  return ++m_dwRefCount;

HRESULT QueryInterface( REFIID iid, void ** ppvObject)
    if( IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IDccManSink))
        *ppvObj = (IDccManSink *)this;
        *ppvObj = NULL;
        return E_NOINTERFACE;

    return S_OK;
ULONG Release(void)
    ULONG   ul = m_dwRefCount;

    if (!--m_dwRefCount)
        delete this;

    return ul;

Other methods you have to implement manually
Good luck!
LukaKropAuthor Commented:
Thank you for your help....

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now