Hi, if your interfaces are located in a type library, you need to load the type lib first:
from comtypes.client import GetModule GetModule(('{TYPELIB_GUID}', VERSION_MAJOR, VERSION_MINOR)) or your can use the dll directly: GetModule('typelib.dll') When correctly loaded, you should be able to import the generated python file import comtypes.gen.YOUR_TYPELIB_ALIAS then you can do the type cast to your interface instance = smi.QueryInterface(comtypes.gen.YOUR_TYPELIB_ALIAS.IYourInterface) //Jan Von: takeshi ikeya [mailto:takeshi.ik...@gmail.com] Gesendet: Donnerstag, 19. April 2012 06:09 An: comtypes-users Betreff: [comtypes-users] How to create an instance of Interface of a COM. Could anyone help me ? I'm trying to use Animatics' SMIEngine from comtypes. It's expalined here. http://www.animatics.com/products/software/animatics/code-dev-software/smiengine.html I installed SMIEngine. I could create an instance of 'SMIEngine.SMIHost'. This is what I did. >> import comtypes.client as cc >> smi = cc.CreateObject('SMIEngine.SMIHost') Next, I must create an instance of ISMIComm. >> smiCom = smi.QuerryInterface( ?? ) At this point, I lost my way. I looked it with OLE/COM Object Viewer. SMIHost Class +--ISMICMotion +--ISMIComm +--ISMIPath +--ISupportErrorInfo +--IUnknown SMIHost Class CLSID = Notes Link +--{ GUID } [<no name.] = SMIHost Class +--{ GUID } [AppID] = { GUID } +--InprocServer32 = C:\WINDOWS\system32\IntegMotorInterface.dll +--InprocServer32 = Both +--ProgID = SMIEngine.SMIHost.1 +--Programmable +--TypeLib = { GUID } +--VersionIndependentProgID = SMIEngine.SMIHost AppID +--{ GUID } = SMIHost Class SMIEngine.SMIHost.1 = SMIHost Class +--CLSID = { GUID } TypeLib = +--{ GUID } +--2.0 = IntegMotorInterface 2.0 Type Library +--0 | +--win32 = C:\WINDOWS\system32\IntegMotorInterface.dll +--FLAGS = 0 +--HELPDIR = ISMIComm Interface = +--{ GUID } = ISMIComm +--ProxyStubClsid = { GUID } +--ProxyStubClsid32 = { GUID } +--TypeLib [<no name>] = { GUID } +--TypeLib [Version] = 2.0 CLSID = Notes Link +--{ GUID } = PSOAInterface +--InprocServer = ole2disp.dll +--InprocServer32 [<no nmae>] = oleaut32.dll +--InprocServer32 [ThreadingModel] = Both +--InprocServer32 [InprocServer32] = VA``Z-GMs8]CT3n....eX)y TypeLib = +--{ GUID } +--2.0 = IntegMotorInterface 2.0 Type Library +--0 | +--win32 = C:\WINDOWS\system32\IntegMotorInterface.dll +--FLAGS = 0 +--HELPDIR = 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