codekingpro/portable-devtools
114k
1"""General utility functions common to client and server.2 3 This module contains a collection of general purpose utility functions.4"""5import pythoncom6import win32api7import win32con8 9 10def IIDToInterfaceName(iid):11 """Converts an IID to a string interface name.12 13 Used primarily for debugging purposes, this allows a cryptic IID to14 be converted to a useful string name. This will firstly look for interfaces15 known (ie, registered) by pythoncom. If not known, it will look in the16 registry for a registered interface.17 18 iid -- An IID object.19 20 Result -- Always a string - either an interface name, or '<Unregistered interface>'21 """22 try:23 return pythoncom.ServerInterfaces[iid]24 except KeyError:25 try:26 try:27 return win32api.RegQueryValue(28 win32con.HKEY_CLASSES_ROOT, "Interface\\%s" % iid29 )30 except win32api.error:31 pass32 except ImportError:33 pass34 return str(iid)35 