home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activepython / ActivePython-2.1.1.msi / Python21_win32com_util.py < prev    next >
Encoding:
Python Source  |  2001-07-26  |  960 b   |  33 lines

  1. """General utility functions common to client and server.
  2.  
  3.   This module contains a collection of general purpose utility functions.
  4. """
  5. import pythoncom
  6. import win32api, win32con
  7.  
  8. def IIDToInterfaceName(iid):
  9.     """Converts an IID to a string interface name.  
  10.     
  11.     Used primarily for debugging purposes, this allows a cryptic IID to
  12.     be converted to a useful string name.  This will firstly look for interfaces
  13.     known (ie, registered) by pythoncom.  If not known, it will look in the
  14.     registry for a registered interface.
  15.  
  16.     iid -- An IID object.
  17.  
  18.     Result -- Always a string - either an interface name, or '<Unregistered interface>'
  19.     """
  20.     try:
  21.         return pythoncom.ServerInterfaces[iid]
  22.     except KeyError:
  23.         try:
  24.             try:
  25.                 return win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, "Interface\\%s" % iid) + \
  26.                     "(unregistered)"
  27.             except win32api.error:
  28.                 pass
  29.         except ImportError:
  30.             pass
  31.         return "<Unregistered interface>"
  32.  
  33.