Am 10.04.2014 12:19, schrieb Eko S.Wibowo: > Hi dear community, > > I am trying to use INetCfg from python using comtypes > http://msdn.microsoft.com/en-us/library/ff547694(v=vs.85).aspx > > After hours of research, finally I am able to create its TLB file and > use it in the following unittest code. > [...] > > But I still unable to instantiate netcfgclass. It only a function return > value, not a pointer as I expected it to be > This is the INetCfgClass implementation automatically created by comtypes: > class INetCfg(IUnknown): > _case_insensitive_ = True > _iid_ = GUID('{C0E8AE93-306E-11D1-AACF-00805FC1270E}') > _idlflags_ = [] > INetCfg._methods_ = [ > COMMETHOD([], HRESULT, 'Initialize', > ( ['in'], c_void_p, 'pvReserved' )), > COMMETHOD([], HRESULT, 'Uninitialize'), > COMMETHOD([], HRESULT, 'Apply'), > COMMETHOD([], HRESULT, 'Cancel'), > COMMETHOD([], HRESULT, 'EnumComponents', > ( ['in'], POINTER(GUID), 'pguidClass' ), > ( ['out'], POINTER(POINTER(IEnumNetCfgComponent)), > 'ppenumComponent' )), > COMMETHOD([], HRESULT, 'FindComponent', > ( ['in'], WSTRING, 'pszwInfId' ), > ( ['out'], POINTER(POINTER(INetCfgComponent)), > 'pComponent' )), > COMMETHOD([], HRESULT, 'QueryNetCfgClass', > ( ['in'], POINTER(GUID), 'pguidClass' ), > ( ['in'], POINTER(GUID), 'riid' ), > ( ['out'], POINTER(c_void_p), 'ppvObject' )), > ] > > > How do I properly call QueryNetCfgClass ?
You should change the generated code for the QueryNetCfgClass so that the 'out' parameter is a POINTER(POINTER(IUnknown)), then you can try to QueryInterface the result to whatever you need (whatever interface the returned objects implements). Change the generated code to this: COMMETHOD([], HRESULT, 'QueryNetCfgClass', ( ['in'], POINTER(GUID), 'pguidClass' ), ( ['in'], POINTER(GUID), 'riid' ), ## ( ['out'], POINTER(c_void_p), 'ppvObject' )), ( ['out'], POINTER(POINTER(IUnknown)), 'ppvObject' )), Thomas ------------------------------------------------------------------------------ Put Bad Developers to Shame Dominate Development with Jenkins Continuous Integration Continuously Automate Build, Test & Deployment Start a new project now. Try Jenkins in the cloud. http://p.sf.net/sfu/13600_Cloudbees _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users