MessengerAPI type library - IDispatch enum type problem 
Author Message
 MessengerAPI type library - IDispatch enum type problem

I'm having trouble hooking in to the MessengerAPI (Messenger 4.5 and later)
events via ATL. I get events that don't contain a MISTATUS type parameter,
but events that do contain a MISTATUS fail because I have the wrong type in
the methods that are hooked to these events.

The code follows. Note that in order to get at the type library, I used
OleView to extract it and saved it as a TLB. This is because msmsgs.exe
contains more than one type library, and I couldn't access anything but the
first type library in my idl when I did an importlib("msmsgs.exe"). I needed
to do that for an outgoing interface on another object that raises the same
events. There's another question: how do you get at the other type libraries
with importlib?

Anyhow, in the following code, everything works until dispid 0x407 is
raised. Tracing the call stack, I see that the parameters that are being
passed for that method are VT_I4 (as expected) and VT_USERDEFINED. This is
despite the fact that in my MessengerAPI.tlb, MISTATUS is an enum (and
therefore should be a VT_I4 as well, I think).

What is going on?!


///// The object that will act as a sink for events from Messenger
class  CSink :
 public IDispEventImpl<1,CSink,&DIID_DMessengerEvents,
 CComPtr<IUnknown> wrappedMessenger;
 CEventSource * proxyObj;
 CSink(CEventSource * proxy) {
   proxyObj = proxy;
   HRESULT res = CoCreateInstance(CLSID_Messenger, 0, CLSCTX_ALL,
               IID_IUnknown, (void **)&wrappedMessenger);
   HRESULT result = this->DispEventAdvise(wrappedMessenger);


 virtual ~CSink();

HRESULT __stdcall Tester(LONG hr, MISTATUS blah) {
   return S_OK;


    SINK_ENTRY_EX(1, DIID_DMessengerEvents, 0x400 /*Dispid*/, OnSignin
/*EventHandler */)
    SINK_ENTRY_EX(1, DIID_DMessengerEvents, 0x401, OnSignout)
    SINK_ENTRY_EX(1, DIID_DMessengerEvents, 0x405, OnMyFriendlyNameChange)
//    SINK_ENTRY_EX(1, DIID_DMessengerEvents, 0x407, OnMyStatusChange)
    SINK_ENTRY_EX(1, DIID_DMessengerEvents, 0x407, Tester)
    SINK_ENTRY_EX(1, DIID_DMessengerEvents, 0x415, OnGroupAdded)

HRESULT __stdcall OnSignout();
HRESULT __stdcall OnSignin(LONG hr);
HRESULT __stdcall OnMyStatusChange(LONG hr, MISTATUS mMyStatus);
HRESULT __stdcall OnMyFriendlyNameChange(LONG hr, BSTR
HRESULT __stdcall OnGroupAdded(LONG hr, IDispatch * pMGroup);


Wed, 23 Jun 2004 12:50:55 GMT  
 MessengerAPI type library - IDispatch enum type problem
To save anyone wasting a reply, I found out that it's a bug in ATL:  Q237771

Wed, 23 Jun 2004 17:03:40 GMT  
 [ 2 post ] 

 Relevant Pages 

1. HRESULT return type turns into void when adding class from type library

2. Problem with enum type

3. Problem with #import msado15.dll :enum type redefinition

4. Type Casting between Base and Derived Type (Serialization of objects with Type members)

5. Variables and types of type "Type"

6. type problems with .net types *arrgh*

7. How to pass out and cast later type of IDispatch **

8. Type casting ADO recordset with IDispatch

9. IDISPATCH or the exact object type: Help?

10. IDISPATCH or the exact object type: help?

11. How to declare vraible of type IDispatch?

12. Type Object and IDispatch


Powered by phpBB® Forum Software