TAPI ITAddressDeviceSpecificEven 如何从事件中获取所有数据?

TAPI ITAddressDeviceSpecificEven how to get all data from an event?

我正在 Python 中使用 TAPI DLL 试图跟踪发生的所有事件。

处理 ITAddressDeviceSpecificEvent 事件时遇到问题

<win32com.gen_py.Microsoft TAPI 3.0 Type Library.ITAddressDeviceSpecificEvent instance at 0x274862726400>
print(dir(event))
['Address',' CLSID ',' Call ',' _ApplyTypes_ ',' __class__ ',' __delattr__ ',' __dict__ ',' __dir__ ',' __doc__ ',' __eq__ ',' __
format__ ',' __ge__ ',' __getattr__ ',' __getattribute__ ',' __gt__ ',' __hash__ ',' __init__ ',' __init_subclass__ ',' __iter__
',' __le__ ',' __lt__ ',' __module__ ',' __ne__ ',' __new__ ',' __reduce__ ',' __reduce_ex__ ',' __repr__ ',' __setattr__ ',' __s
izeof__ ',' __str__ ',' __subclasshook__ ',' __weakref__ ',' _get_good_object_ ',' _get_good_single_object_ ',' _oleobj_ ',' _p
rop_map_get_ ',' _prop_map_put_ ',' coclass_clsid ',' lParam1 ',' lParam2 ',' lParam3 ']
print(event.__ dict__)
{'_oleobj_': <PyIDispatch at 0x0000003FFFC10C90 with obj at 0x0000003FFC9EEE50>}

当尝试访问地址、调用和 lParam ( 我得到一个错误

地址

pywintypes.com_error: (-2147352573, 'Member not found.', None, None)

通话

pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147221497), None)

lParam1,2,3

pywintypes.com_error: (-2147352559, 'Does not support a collection.', None, None)

如何从此事件中提取数据?对于其他人,这些事件没有造成问题。

导入dll到delphi后,查看了ITAddressDeviceSpecificEvent

的内容
// *********************************************************************//
// Interface: ITAddressDeviceSpecificEvent
// Flags:     (4352) OleAutomation Dispatchable
// GUID:      {3ACB216B-40BD-487A-8672-5CE77BD7E3A3}
// *********************************************************************//
  ITAddressDeviceSpecificEvent = interface(IDispatch)
    ['{3ACB216B-40BD-487A-8672-5CE77BD7E3A3}']
    function Get_Address(out ppAddress: ITAddress): HResult; stdcall;
    function Get_Call(out ppCall: ITCallInfo): HResult; stdcall;
    function Get_lParam1(out pParam1: Integer): HResult; stdcall;
    function Get_lParam2(out pParam2: Integer): HResult; stdcall;
    function Get_lParam3(out pParam3: Integer): HResult; stdcall;
  end;

有没有人有过这样的经历?

更新:

找了个C语言的例子,可惜里面什么都不懂,能不能转成python?

HRESULT STDMETHODCALLTYPE CMyEventNotification::Event(
   TAPI_EVENT TapiEvent,
   IDispatch * pEvent
)
{
    HRESULT hr = S_OK;
    //...
    switch (TapiEvent) 
    {
        case TE_ADDRESSDEVSPECIFIC:
        {
            ITAddressDeviceSpecificEvent* pITADSEvent = NULL;

            hr = pEvent->QueryInterface( 
                               IID_ITAddressDeviceSpecificEvent,
                               (void **)(&pITADSEvent) );
            // If (hr != S_OK) process the error here...

            // Retrieve data received from the TSP.
            long lParam1=0;
            hr = pITADSEvent->get_lParam1(&lParam1);
            // If (hr != S_OK) process the error here...

            long lParam2=0;
            hr = pITADSEvent->get_lParam2(&lParam2);
            // If (hr != S_OK) process the error here...

            long lParam3=0; 
            hr = pITADSEvent->get_lParam3(&lParam3);
            // If (hr !=S_OK) process the error here...

            // Process the data here.
            // ...
            pITADSEvent->Release();
            break;
        }

        case TE_PHONEDEVSPECIFIC:
        {
            ITPhoneDeviceSpecificEvent* pITPhEvent = NULL;

            hr = pEvent->QueryInterface( 
                            IID_ITPhoneDeviceSpecificEvent,
                            (void **)(&pITPhEvent) );
            // If (hr != S_OK) process the error here...

            // Retrieve data received from the TSP.
            long lParam1=0;
            hr = pITPhEvent->get_lParam1(&lParam1);
            // If (hr != S_OK) process the error here...

            long lParam2=0;
            hr = pITPhEvent->get_lParam2(&lParam2);
            // If (hr != S_OK) process the error here...

            long lParam3=0;
            hr = pITPhEvent->get_lParam3(&lParam3);
            // If (hr != S_OK) process the error here...

            // Process the data here.
            //...
            pITPhEvent->Release();
            break;
        }
        //...
    } // end of switch 
    //...
}

没有解决办法。 pywin32 无法正确解析 dll,因此无法进一步处理此类事件