def CreateInstance(clsid, reqIID):
 try:
  addnPaths = win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, (regAddnPath % clsid)).split(';')
  for newPath in addnPaths:
   if (newPath not in sys.path):
    sys.path.insert(0, newPath)
 except win32api.error:
  pass
 try:
  policy = win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, (regPolicy % clsid))
  policy = resolve_func(policy)
 except win32api.error:
  policy = DefaultPolicy
 try:
  dispatcher = win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, (regDispatcher % clsid))
  if dispatcher:
   dispatcher = resolve_func(dispatcher)
 except win32api.error:
  dispatcher = None
 if dispatcher:
  retObj = dispatcher(policy, None)
 else:
  retObj = policy(None)
 return retObj._CreateInstance_(clsid, reqIID)

def CreateInstance ( clsid , reqIID ) : try : addnPaths = win32api . RegQueryValue ( win32con . HKEY_CLASSES_ROOT , ( regAddnPath % clsid ) ) . split ( ';' ) for newPath in addnPaths : if ( newPath not in sys . path ) : sys . path . insert ( 0 , newPath ) except win32api . error : pass try : policy = win32api . RegQueryValue ( win32con . HKEY_CLASSES_ROOT , ( regPolicy % clsid ) ) policy = resolve_func ( policy ) except win32api . error : policy = DefaultPolicy try : dispatcher = win32api . RegQueryValue ( win32con . HKEY_CLASSES_ROOT , ( regDispatcher % clsid ) ) if dispatcher : dispatcher = resolve_func ( dispatcher ) except win32api . error : dispatcher = None if dispatcher : retObj = dispatcher ( policy , None ) else : retObj = policy ( None ) return retObj . _CreateInstance_ ( clsid , reqIID )
create a new instance of the specified iid the com framework **always** calls this function to create a new instance for the specified clsid .