日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

win32com调用ATL编写的COM组件

發(fā)布時間:2024/3/26 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 win32com调用ATL编写的COM组件 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

IDL文件

import "oaidl.idl"; import "ocidl.idl";[object,uuid(B325C169-61FA-4513-9DB1-0CC231CCB633),dual,nonextensible,helpstring("IComTestClass Interface"),pointer_default(unique) ] interface IComTestClass : IDispatch{[id(1), helpstring("method Method1")] HRESULT Method1(LONG arg1); }; [uuid(9098C7D5-91BA-4C0C-837B-DB81C3DBA6AE),version(1.0),helpstring("ComTest 1.0 Type Library") ] library ComTestLib {importlib("stdole2.tlb");[uuid(F41DAE07-8D10-430B-8834-06BB4B9AE8A2),helpstring("_IComTestClassEvents Interface")]dispinterface _IComTestClassEvents{properties:methods:[id(1), helpstring("method Event1")] HRESULT Event1(LONG arg1);};[uuid(2961361E-8E6D-4618-95A8-4DF03B65BDC3),helpstring("ComTestClass Class")]coclass ComTestClass{[default] interface IComTestClass;[default, source] dispinterface _IComTestClassEvents;}; };
Method1中觸發(fā)事件

STDMETHODIMP CComTestClass::Method1(LONG arg1) {// TODO: Add your implementation code hereFire_Event1(arg1);return S_OK; }

win32com調(diào)用組件

import win32com.clientclass EventHandler:def OnEvent1(self, val):print(val)o = win32com.client.DispatchWithEvents("ComTest.ComTestClass", EventHandler) o.Method1(23)


總結(jié)

以上是生活随笔為你收集整理的win32com调用ATL编写的COM组件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。