Hi all, I've had cause to instantiate a COM class which is not registered on the system. To do this, one uses DllGetClassObject on the dll and then calls CreateInstance on the resulting IClassFactory.
IClassFactory::CreateInstance is defined as: HRESULT CreateInstance( [in] IUnknown *pUnkOuter, [in] REFIID riid, [out] void **ppvObject ); However, in comtypes.server.IClassFactory, CreateInstance is defined as follows: _methods_ = [ comtypes.STDMETHOD(comtypes.HRESULT, "CreateInstance", [ctypes.c_int, ctypes.POINTER(comtypes.GUID), ctypes.POINTER(ctypes.c_ulong)]), ... The final parameter being declared as c_ulong makes life a little painful. In order to use it, you have to do something like: instance = ctypes.c_ulong() factory.CreateInstance(0, interface._iid_, ctypes.byref(instance)) instance = ctypes.POINTER(interface)(instance.value) First of all, is there a reason that last parameter is c_ulong instead of c_void_p or the like? Second, is there any chance we could make this more Pythonic like the recent IServiceProvider.QueryInterface? Something like: instance = factory.CreateInstance(interface=interface) I'm curious as to how frequently this is already used, as such a change would break existing usage. Jamie -- James Teh Email/MSN Messenger/Jabber: ja...@jantrid.net Web site: http://www.jantrid.net/ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users