Вопрос по COM Уважаемые программеры дайте совет и сильно не бейте ногами я новичок в COM.. Задачка: необходимо получить событие о том что открылось новое окно, т.е. dispIdMember = 200 Делаю так: Мой test.inc файл, мои гуиды: Код (Text): ;MyEventClass - DShellWindowsEvents sIID___MyEventClass TEXTEQU <{0FE4106E0H, 0399AH, 011D0H, {0A4H, 08CH, 000H, 0A0H, 0C9H, 00AH, 08FH, 039H}}> ;shdocVw ; {EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B} sLIBID___MyEventClass TEXTEQU <{0EAB22AC0H, 030C1H, 011CFH, {0A7H, 0EBH, 000H, 000H, 0C0H, 05BH, 0AEH, 00BH}}> ; {EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B} sCLSID___MyEventClass TEXTEQU <{09BA05972H, 0F6A8H, 011CFH, {0A4H, 042H, 000H, 0A0H, 0C9H, 00AH, 08FH, 039H}}> _vt__MyEventClass MACRO CastName:REQ ; IDispatch methods _vtIDispatch CastName ; __MyEventClass methods &CastName&GetTypeInfoCount comethod2 ? &CastName&GetTypeInfo comethod4 ? &CastName&GetIDsOfNames comethod6 ? &CastName&invoke_ comethod9 ? ENDM __MyEventClass STRUCT _vt__MyEventClass __MyEventClass __MyEventClass ENDS IShellWindows STRUCT DWORD IShellWindows_QueryInterface comethod3 ? IShellWindows_AddRef comethod1 ? IShellWindows_Release comethod1 ? IShellWindows_GetTypeInfoCount comethod2 ? IShellWindows_GetTypeInfo comethod4 ? IShellWindows_GetIDsOfNames comethod6 ? IShellWindows_Invoke comethod9 ? IShellWindows_Get_Count comethod2 ? IShellWindows_Item comethod3 ? IShellWindows__NewEnum comethod2 ? IShellWindows ENDS ===================================== далее основной файл test.asm объявляю мой класс (по примерам из масма): Код (Text): MyEventClass ClassItem { pCLSID___MyEventClass, DISPINTERFACE + SUPPLY_TYPE_INFO, \ OFFSET IMyEventTypeLibInfo, OFFSET IMyEventIMap, \ NULL, NULL, NULL, SIZEOF IMyEventObject } IMyEventIMap InterfaceItem { pIID___MyEventClass, OFFSET vtableIMyEvent } END_INTERFACE_MAP ; describe the type libraries IMyEventTypeLibInfo TypeLibInfo { pLIBID___MyEventClass, 1, 0 } IMyEventObjData STRUCT ; IMyEvent object private data struct m_Value DWORD 0 ; Value (private data member) IMyEventObjData ENDS IMyEventObject STRUCT ObjectData0 ObjectData { } ; base values ; IMyEventObjData0 IMyEventObjData { } ; custom object data does not exist ObjectEntry0 ObjectEntry { } ; delegated Unknown ObjectEntry1 ObjectEntry { } ; IMyEvent IMyEventObject ENDS vtableIMyEvent __MyEventClass {pvtIDispatch} затем мой invoke: Invoke_ PROC uses __this this_:DWORD, dispIdMember:DISPID, riid:DWORD, lcid:LCID, wFlags:WORD, pDispParams:DWORD, pVarResult:DWORD, pExcepInfo:DWORD, puArgErr:DWORD mov __this, this_ pObjectData this_, edx mov eax, (IMyEventObjData ptr [edx]).m_Value ; get object data value mov ecx, dispIdMember ; get ptr to variable for return mov [ecx], eax ; mov value to variable xor eax, eax ; return S_OK .if dispIdMember == 200 invoke MessageBox, NULL, ADDR sEvent, ADDR DlgName, MB_OK .endif ret Invoke_ endp Затем реализация подключения к моему sink интерфейсу: Код (Text): ConnectEvent PROC pIAny:DWORD, pISink:DWORD, pIID_IEvent:DWORD, pdwCookie:DWORD ; pIAny Interface pointer that we wish to connect to. May not be NULL. ; pISink Callback Interface pointer. May not be NULL. ; pIID_IEvent ref of event IID to connect up. May not be NULL. ; pdwCookie ref of connection cookie. Must be NULL. LOCAL _pICPC:DWORD, _pICP:DWORD coinvoke pIAny, IUnknown, QueryInterface, ADDR IID_CPC, ADDR _pICPC .IF_SUCCEEDED ; Our object supports events, let's get one! coinvoke _pICPC, IConnectionPointContainer, FindConnectionPoint, pIID_IEvent, ADDR _pICP .IF_SUCCEEDED ; advise we want events here .IF_SUCCEEDED coinvoke _pICP, IConnectionPoint, Advise, pISink, pdwCookie ; now we have our event link, release the intermediate interfaces coinvoke _pICP, IUnknown, Release .ENDIF .ENDIF coinvoke _pICPC, IUnknown, Release .ENDIF ret ConnectEvent ENDP и наконец сама программа: Код (Text): testpproc proc mov pMyEventClass, 0 invoke CoInitialize, 0 invoke CoCreateInstance,offset CLSID_ShellWindows, 0, CLSCTX_ALL, addr IID_ShellWindows, addr pps .IF eax == S_OK invoke AllocObject, ADDR p_IMyEvent, OFFSET MyEventClass, NULL, NULL .IF_FAILED jmp BadStart .ENDIF invoke ConnectEvent, pps,p_IMyEvent,pIID___MyEventClass, ADDR dwCookie .IF pMyEventClass != 0 ; we have an object, release it coinvoke pMyEventClass, __MyEventClass, Release .ENDIF ret BadStart: invoke MessageBox, NULL, ADDR sFatal2, ADDR sFatal1, MB_OK or MB_ICONSTOP .endif testpproc endp start: invoke CreateThread, NULL, 0, addr testpproc, NULL, NULL, 0 invoke Sleep,30000 call ExitProcess end start В принципе это все но почемуто не отлавливаются события о создании нового окна, а просто при создании виснет приложение и это видимо изза постоянных ConnectEvent'ов. Метод Invoke_ реализован но почемуто не опрашивается. В чем может быть дело, дайте совет. спасибо