win32com调用ATL编写的COM组件
2014-12-25 10:39
399 查看
IDL文件
Method1中触发事件
win32com调用组件
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 here Fire_Event1(arg1); return S_OK; }
win32com调用组件
import win32com.client class EventHandler: def OnEvent1(self, val): print(val) o = win32com.client.DispatchWithEvents("ComTest.ComTestClass", EventHandler) o.Method1(23)
相关文章推荐
- ATL编写的COM组件调用启动页面的Javascript函数
- C#调用手动编写的COM组件(非ATL向导生成,参考上一篇手把手写COM组件)
- VBS调用ATL编写的COM组件
- 用ATL编写COM并调用
- 使用.NET2.0编写COM组件供VB调用
- Jawin –Java/Win32互动项目:可调用DLL及COM的调用项目
- 在VC中调用VB编写的COM组件范例
- All-In-One Code Framework(AIO): 如何使用C#编写进程外的COM组件 (How to write an out-of-proc COM server in C#)
- 用visual C++ 2008 速成版编写EXCEL程序--测试托管程序调用COM组件
- C#调用C++编写的COM DLL封装库的问题解决方案
- PHP4调用自己编写的COM组件
- C#调用C++编写的COM DLL
- com调用的几种方法 及 C#调用C++编写的的COM DLL收藏
- C#调用C++编写的COM DLL
- 编写能被com组件调用的客户端
- Java如何通过VC调用VB编写的COM
- C#与DLL和COM的混合编程(2)-C#调用COM组件
- 如何用PHP调用自己编写的COM组件?
- C#调用C++编写的COM DLL
- com调用的几种方法 及 C#调用C++编写的的COM DLL