Am 12.04.2012 09:55, schrieb Jan Wedel: > I think IClassFactory.LockServer is exactly what I'm looking for. > However, I do not know how, when and where I should be able to access > this method. I checked the sources and found that the factory instance > gets lost somewhere in COMObject. [...]
You could somehow patch comtypes to make the factory instance available in the COM object that it has created, but there are probably much easier ways. You could increment the COM refcount of your object from the object itself, by calling AddRef() on it. In the COMObject base class, and by comtypes-magic, the method that must be called is self.IUnknown_AddRef(None). Calling self.IUnknown_Release(None) will then decrement the refcount again if your are done and eventually end the process if there are no other references to it. The 'official' way, according to MSDN, seems to be the CoLockObjectExternal function [1]; in comtypes it is not exposed but you can define a method in your COMObject based class like this: def CoLockObjectExternal(self, fLock, fLastUnlockReleases): punk = self._com_pointers_.values()[0] windll.oledll.ole32.CoLockObjectExternal(punk, fLock, fLastUnlockReleases) I'm not really sure about the differences in the two approaches. Thomas [1] http://msdn.microsoft.com/en-us/library/windows/desktop/ms680592%28v=vs.85%29.aspx ------------------------------------------------------------------------------ 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