Ok, your first attempt didnt work because you needed a string:
cc.GetModule("{BC26FBAC-00E1-11D4-B5D0-00600831E1F3}", 2, 0) When using QueryInterface, you need an interface ;) That means: smiCom = smi.QueryInterface(comtypes.gen.INTEGMOTORINTERFACELib.IMyInterface) where you should replace "IMyInterface" with the name of the interface you need. Von: takeshi ikeya [mailto:takeshi.ik...@gmail.com] Gesendet: Donnerstag, 19. April 2012 13:34 An: comtypes-users@lists.sourceforge.net Betreff: Re: [comtypes-users] How to create an instance of Interface of a COM. Thank you Jan for your quick responce. I tried according to your advice. >>> import comtypes.client as cc >>> smi = cc.CreateObject('SMIEngine.SMIHost') this is OK >>> cc.GetModule({BC26FBAC-00E1-11D4-B5D0-00600831E1F3}, 2, 0) SyntaxError: invalid syntax and -11D4- is hilighted So, I tried this >>> cc.GetModule('IntegMotorInterface.dll') # Generating comtypes.gen._BC26FBAC_00E1_11D4_B5D0_00600831E1F3_0_2_0 # Generating comtypes.gen.INTEGMOTORINTERFACELib <module 'comtypes.gen.INTEGMOTORINTERFACELib' from 'C:\Python27\lib\site-packages\comtypes\gen\_BC26FBAC_00E1_11D4_B5D0_006 00831E1F3_0_2_0.py'> seems OK >>> import comtypes.gen.INTEGMOTORINTERFACELib No problem, as this far. But >>> smiCom = smi.QueryInterface(comtypes.gen.INTEGMOTORINTERFACELib) Traceback (most recent call last): File "<pyshell#5>", line 1, in <module> smiCom = smi.QueryInterface(comtypes.gen.INTEGMOTORINTERFACELib) File "C:\Python27\lib\site-packages\comtypes\__init__.py", line 1075, in QueryInterface p = POINTER(interface)() TypeError: must be a ctypes type What is this Error ? How can I go ahead ? Regards ikeya ------------------------------------------------------------------------------ For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2 _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users