home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Shareware / Comunicatii / jyte / jyte.exe / factory.py < prev    next >
Text File  |  2000-03-02  |  788b  |  23 lines

  1. # Class factory utilities.
  2. import pythoncom
  3.  
  4. def RegisterClassFactories(clsids, flags = None, clsctx = None):
  5.     """Given a list of CLSID, create and register class factories.
  6.     
  7.        Returns a list, which should be passed to RevokeClassFactories
  8.     """
  9.     if flags is None:    flags = pythoncom.REGCLS_MULTIPLEUSE|pythoncom.REGCLS_SUSPENDED
  10.     if clsctx is None: clsctx = pythoncom.CLSCTX_LOCAL_SERVER
  11.     ret = []
  12.     for clsid in clsids:
  13.         # Some server append '-Embedding' etc
  14.         if clsid[0] not in ['-', '/']:
  15.             factory = pythoncom.MakePyFactory(clsid)
  16.             regId = pythoncom.CoRegisterClassObject(clsid, factory, clsctx, flags)
  17.             ret.append((factory, regId))
  18.     return ret
  19.  
  20. def RevokeClassFactories(infos):
  21.     for factory, revokeId in infos:
  22.         pythoncom.CoRevokeClassObject(revokeId)
  23.