win32com调用ATL编写的COM组件
生活随笔
收集整理的這篇文章主要介紹了
win32com调用ATL编写的COM组件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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中觸發事件 STDMETHODIMP CComTestClass::Method1(LONG arg1) {// TODO: Add your implementation code hereFire_Event1(arg1);return S_OK; }
win32com調用組件
import win32com.clientclass EventHandler:def OnEvent1(self, val):print(val)o = win32com.client.DispatchWithEvents("ComTest.ComTestClass", EventHandler) o.Method1(23)總結
以上是生活随笔為你收集整理的win32com调用ATL编写的COM组件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电脑android模拟器下载地址,灵猫传
- 下一篇: 加密器