def UnpackDEV_BROADCAST(lparam): # guard for 0 here, otherwise PyMakeBuffer will create a new buffer. if lparam == 0: return None hdr_size = struct.calcsize("iii") hdr_buf = win32gui.PyMakeBuffer(hdr_size, lparam) size, devtype, reserved = struct.unpack("iii", hdr_buf) rest = win32gui.PyMakeBuffer(size - hdr_size, lparam + hdr_size) extra = x = {} if devtype == win32con.DBT_DEVTYP_HANDLE: # 2 handles, a GUID, a LONG and possibly an array following... fmt = "PP16sl" x['handle'], x['hdevnotify'], guid_bytes, x['nameoffset'] = \ struct.unpack(fmt, rest[:struct.calcsize(fmt)]) x['eventguid'] = pywintypes.IID(guid_bytes, True) elif devtype == win32con.DBT_DEVTYP_DEVICEINTERFACE: # guid, null-terminated name x['classguid'] = pywintypes.IID(rest[:16], 1) name = rest[16:] if '\0' in name: name = name.split('\0', 1)[0] x['name'] = name elif devtype == win32con.DBT_DEVTYP_VOLUME: # int mask and flags x['unitmask'], x['flags'] = struct.unpack("II", rest[:struct.calcsize("II")]) else: raise NotImplementedError("unknown device type %d" % (devtype, )) return DEV_BROADCAST_INFO(devtype, **extra)
def UnpackDEV_BROADCAST(lparam): if lparam == 0: return None hdr_format = "iii" hdr_size = struct.calcsize(hdr_format) hdr_buf = win32gui.PyGetMemory(lparam, hdr_size) size, devtype, reserved = struct.unpack("iii", hdr_buf) # Due to x64 alignment issues, we need to use the full format string over # the entire buffer. ie, on x64: # calcsize('iiiP') != calcsize('iii')+calcsize('P') buf = win32gui.PyGetMemory(lparam, size) extra = x = {} if devtype == win32con.DBT_DEVTYP_HANDLE: # 2 handles, a GUID, a LONG and possibly an array following... fmt = hdr_format + "PP16sl" _, _, _, x['handle'], x['hdevnotify'], guid_bytes, x['nameoffset'] = \ struct.unpack(fmt, buf[:struct.calcsize(fmt)]) x['eventguid'] = pywintypes.IID(guid_bytes, True) elif devtype == win32con.DBT_DEVTYP_DEVICEINTERFACE: fmt = hdr_format + "16s" _, _, _, guid_bytes = struct.unpack(fmt, buf[:struct.calcsize(fmt)]) x['classguid'] = pywintypes.IID(guid_bytes, True) x['name'] = win32gui.PyGetString(lparam + struct.calcsize(fmt)) elif devtype == win32con.DBT_DEVTYP_VOLUME: # int mask and flags fmt = hdr_format + "II" _, _, _, x['unitmask'], x['flags'] = struct.unpack( fmt, buf[:struct.calcsize(fmt)]) else: raise NotImplementedError("unknown device type %d" % (devtype, )) return DEV_BROADCAST_INFO(devtype, **extra)
def testGUID(self): s = "{00020400-0000-0000-C000-000000000046}" iid = pywintypes.IID(s) iid2 = pywintypes.IID(ob2memory(iid), True) self.assertEquals(iid, iid2) self.assertRaises(ValueError, pywintypes.IID, str2bytes('00'), True) # too short self.assertRaises(TypeError, pywintypes.IID, 0, True) # no buffer
def testGUID(self): s = "{00020400-0000-0000-C000-000000000046}" iid = pywintypes.IID(s) iid2 = pywintypes.IID(ob2memory(iid), True) assert iid == iid2 with pytest.raises(ValueError): pywintypes.IID(str2bytes('00'), True) # too short with pytest.raises(TypeError): pywintypes.IID(0, True) # no buffer
def MimeToMapi (self, mimestream, m, flag = 0) : if self.converter == None : ## CLSID_IConverterSession clsid = pywintypes.IID('{4e3a7680-b77a-11d0-9da5-00c04fd65685}') ## IID_IConverterSession iid = pywintypes.IID('{4b401570-b77b-11d0-9da5-00c04fd65685}') tmp = pythoncom.CoCreateInstance (clsid, None, pythoncom.CLSCTX_INPROC_SERVER, pythoncom.IID_IUnknown) self.converter = tmp.QueryInterface (iid) Istrm = util.wrap (util.FileStream(mimestream), pythoncom.IID_IStream) self.converter.MIMEToMAPI(Istrm, m, flag)
def GetGeneratedInfos(): zip_pos = win32com.__gen_path__.find(".zip\\") if zip_pos >= 0: import zipfile zip_file = win32com.__gen_path__[:zip_pos + 4] zip_path = win32com.__gen_path__[zip_pos + 5:].replace("\\", "/") zf = zipfile.ZipFile(zip_file) infos = {} for n in zf.namelist(): if not n.startswith(zip_path): continue base = n[len(zip_path) + 1:].split("/")[0] try: iid, lcid, major, minor = base.split("x") lcid = int(lcid) major = int(major) minor = int(minor) iid = pywintypes.IID("{" + iid + "}") except ValueError: continue except pywintypes.com_error: # invalid IID continue infos[(iid, lcid, major, minor)] = 1 zf.close() return list(infos.keys()) else: # on the file system files = glob.glob(win32com.__gen_path__ + "\\*") ret = [] for file in files: if not os.path.isdir(file) and not os.path.splitext( file)[1] == ".py": continue name = os.path.splitext(os.path.split(file)[1])[0] try: iid, lcid, major, minor = name.split("x") iid = pywintypes.IID("{" + iid + "}") lcid = int(lcid) major = int(major) minor = int(minor) except ValueError: continue except pywintypes.com_error: # invalid IID continue ret.append((iid, lcid, major, minor)) return ret
def serve(clsid="{506e67c3-55b5-48c3-a035-eed5deea7d6d}"): """Launch the COM server, clsid is the XLPython objectok class id """ clsid = pywintypes.IID(clsid) # Ovveride CreateInstance in default policy to instantiate the XLPython object --- BaseDefaultPolicy = win32com.server.policy.DefaultPolicy class MyPolicy(BaseDefaultPolicy): def _CreateInstance_(self, reqClsid, reqIID): if reqClsid == clsid: return serverutil.wrap(XLPython(), reqIID) else: return BaseDefaultPolicy._CreateInstance_(self, clsid, reqIID) win32com.server.policy.DefaultPolicy = MyPolicy # Create the class factory and register it factory = pythoncom.MakePyFactory(clsid) clsctx = pythoncom.CLSCTX_LOCAL_SERVER flags = pythoncom.REGCLS_MULTIPLEUSE | pythoncom.REGCLS_SUSPENDED revokeId = pythoncom.CoRegisterClassObject(clsid, factory, clsctx, flags) pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId()) pythoncom.CoResumeClassObjects() print('xlwings server running, clsid=%s' % clsid) pythoncom.PumpMessages() pythoncom.CoRevokeClassObject(revokeId) pythoncom.CoUninitialize()
def Rebuild(verbose=1): """Rebuild the cache indexes from the file system. """ clsidToTypelib.clear() files = glob.glob(win32com.__gen_path__ + "\\*.py") if verbose and len( files): # Dont bother reporting this when directory is empty! print "Rebuilding cache of generated files for COM support..." for file in files: name = os.path.splitext(os.path.split(file)[1])[0] try: iid, lcid, major, minor = string.split(name, "x") ok = 1 except ValueError: ok = 0 if ok: try: iid = pywintypes.IID("{" + iid + "}") except pywintypes.com_error: ok = 0 if ok: if verbose: print "Checking", name try: AddModuleToCache(iid, lcid, major, minor, verbose, 0) except: print "Could not add module %s - %s: %s" % ( name, sys.exc_info()[0], sys.exc_info()[1]) else: if verbose and name[0] != '_': print "Skipping module", name if verbose and len( files): # Dont bother reporting this when directory is empty! print "Done." _SaveDicts()
def GetActiveObject(Class, clsctx = pythoncom.CLSCTX_ALL): """ Python friendly version of GetObject's ProgID/CLSID functionality. """ resultCLSID = pywintypes.IID(Class) dispatch = pythoncom.GetActiveObject(resultCLSID) dispatch = dispatch.QueryInterface(pythoncom.IID_IDispatch) return __WrapDispatch(dispatch, Class, resultCLSID = resultCLSID, clsctx = clsctx)
def getevents(clsid): """Determine the default outgoing interface for a class, given either a clsid or progid. It returns a class - you can conveniently derive your own handler from this class and implement the appropriate methods. This method relies on the classes produced by makepy. You must use either makepy or the gencache module to ensure that the appropriate support classes have been generated for the com server that you will be handling events from. Beware of COM circular references. When the Events class is connected to the COM object, the COM object itself keeps a reference to the Python events class. Thus, neither the Events instance or the COM object will ever die by themselves. The 'close' method on the events instance must be called to break this chain and allow standard Python collection rules to manage object lifetimes. Note that DispatchWithEvents() does work around this problem by the use of a proxy object, but if you use the getevents() function yourself, you must make your own arrangements to manage this circular reference issue. Beware of creating Python circular references: this will happen if your handler has a reference to an object that has a reference back to the event source. Call the 'close' method to break the chain. Example: >>>win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}',0,1,1) <module 'win32com.gen_py..... >>> >>> class InternetExplorerEvents(win32com.client.getevents("InternetExplorer.Application.1")): ... def OnVisible(self, Visible): ... print "Visibility changed: ", Visible ... >>> >>> ie=win32com.client.Dispatch("InternetExplorer.Application.1") >>> events=InternetExplorerEvents(ie) >>> ie.Visible=1 Visibility changed: 1 >>> """ # find clsid given progid or clsid clsid = str(pywintypes.IID(clsid)) # return default outgoing interface for that class klass = gencache.GetClassForCLSID(clsid) try: return klass.default_source except AttributeError: # See if we have a coclass for the interfaces. try: return gencache.GetClassForCLSID( klass.coclass_clsid).default_source except AttributeError: return None
def testGUIDRichCmp(self): s = "{00020400-0000-0000-C000-000000000046}" iid = pywintypes.IID(s) self.failIf(s == None) self.failIf(None == s) self.failUnless(s != None) self.failUnless(None != s) if sys.version_info > (3, 0): self.assertRaises(TypeError, operator.gt, None, s) self.assertRaises(TypeError, operator.gt, s, None) self.assertRaises(TypeError, operator.lt, None, s) self.assertRaises(TypeError, operator.lt, s, None)
def testGUIDRichCmp(self): s = "{00020400-0000-0000-C000-000000000046}" iid = pywintypes.IID(s) self.assertFalse(s is None) self.assertFalse(None == s) self.assertTrue(s is not None) self.assertTrue(None != s) if sys.version_info > (3, 0): self.assertRaises(TypeError, operator.gt, None, s) self.assertRaises(TypeError, operator.gt, s, None) self.assertRaises(TypeError, operator.lt, None, s) self.assertRaises(TypeError, operator.lt, s, None)
def GetClassForProgID(progid): """Get a Python class for a Program ID Given a Program ID, return a Python class which wraps the COM object Returns the Python class, or None if no module is available. Params progid -- A COM ProgramID or IID (eg, "Word.Application") """ clsid = pywintypes.IID(progid) # This auto-converts named to IDs. return GetClassForCLSID(clsid)
def serve(clsid="{506e67c3-55b5-48c3-a035-eed5deea7d6d}"): """Launch the COM server, clsid is the XLPython object class id """ clsid = pywintypes.IID(clsid) # Ovveride CreateInstance in default policy to instantiate the XLPython object --- BaseDefaultPolicy = win32com.server.policy.DefaultPolicy class MyPolicy(BaseDefaultPolicy): def _CreateInstance_(self, reqClsid, reqIID): if reqClsid == clsid: return serverutil.wrap(XLPython(), reqIID) else: return BaseDefaultPolicy._CreateInstance_(self, clsid, reqIID) win32com.server.policy.DefaultPolicy = MyPolicy # Create the class factory and register it factory = pythoncom.MakePyFactory(clsid) clsctx = pythoncom.CLSCTX_LOCAL_SERVER flags = pythoncom.REGCLS_MULTIPLEUSE | pythoncom.REGCLS_SUSPENDED revokeId = pythoncom.CoRegisterClassObject(clsid, factory, clsctx, flags) pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId()) pythoncom.CoResumeClassObjects() print('xlwings server running, clsid=%s' % clsid) while True: rc = win32event.MsgWaitForMultipleObjects([idle_queue_event], 0, win32event.INFINITE, win32event.QS_ALLEVENTS) while True: pythoncom.PumpWaitingMessages() if not idle_queue: break task = idle_queue.pop(0) try: task() except: import traceback print("TaskQueue '%s' threw an exeception: %s", task, traceback.format_exc()) pythoncom.CoRevokeClassObject(revokeId) pythoncom.CoUninitialize()
def detail(self, fmtid, pid): try: fmtid = pywintypes.IID(fmtid) except pywintypes.com_error: fmtid = _fmtid_from_name(fmtid) try: pid = int(pid) except(ValueError, TypeError): pid = _pid_from_name(pid) if self.parent: folder = self.parent._folder else: folder = self._folder folder2 = folder.QueryInterface(shell.IID_IShellFolder2) return folder2.GetDetailsEx(self.rpidl, (fmtid, pid))
def PackDEV_BROADCAST_DEVICEINTERFACE(classguid, name=""): if win32gui.UNICODE: # This really means "is py3k?" - so not accepting bytes is OK if not isinstance(name, str): raise TypeError("Must provide unicode for the name") name = name.encode("utf-16le") else: # py2k was passed a unicode object - encode as mbcs. if isinstance(name, str): name = name.encode("mbcs") # 16 bytes for the IID followed by \0 term'd string. rest_fmt = "16s%ds" % len(name) # _make_memory(iid) hoops necessary to get the raw IID bytes. rest_data = (_make_memory(pywintypes.IID(classguid)), name) return PackDEV_BROADCAST(win32con.DBT_DEVTYP_DEVICEINTERFACE, rest_fmt, rest_data)
def testGUIDRichCmp(self): s = "{00020400-0000-0000-C000-000000000046}" iid = pywintypes.IID(s) assert not (s is None) assert not (None == s) assert s is not None assert None != s if sys.version_info > (3, 0): with pytest.raises(TypeError): operator.gt(None, s) with pytest.raises(TypeError): operator.gt(s, None) with pytest.raises(TypeError): operator.lt(None, s) with pytest.raises(TypeError): operator.lt(s, None)
def GetModuleForProgID(progid): """Get a Python module for a Program ID Given a Program ID, return a Python module which contains the class which wraps the COM object. Returns the Python module, or None if no module is available. Params progid -- A COM ProgramID or IID (eg, "Word.Application") """ try: iid = pywintypes.IID(progid) except pywintypes.com_error: return None return GetModuleForCLSID(iid)
def serve(clsid="{506e67c3-55b5-48c3-a035-eed5deea7d6d}"): """Launch the COM server, clsid is the XLPython object class id """ clsid = pywintypes.IID(clsid) # Ovveride CreateInstance in default policy to instantiate the XLPython object --- BaseDefaultPolicy = win32com.server.policy.DefaultPolicy class MyPolicy(BaseDefaultPolicy): def _CreateInstance_(self, reqClsid, reqIID): if reqClsid == clsid: return serverutil.wrap(XLPython(), reqIID) else: return BaseDefaultPolicy._CreateInstance_(self, clsid, reqIID) win32com.server.policy.DefaultPolicy = MyPolicy # Create the class factory and register it factory = pythoncom.MakePyFactory(clsid) clsctx = pythoncom.CLSCTX_LOCAL_SERVER flags = pythoncom.REGCLS_MULTIPLEUSE | pythoncom.REGCLS_SUSPENDED revokeId = pythoncom.CoRegisterClassObject(clsid, factory, clsctx, flags) pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId()) pythoncom.CoResumeClassObjects() msg = 'xlwings server running, clsid=%s' logger.info(msg, clsid) if logger.hasHandlers() else print(msg % clsid) waitables = [idle_queue_event] while True: timeout = TIMEOUT if idle_queue else win32event.INFINITE rc = win32event.MsgWaitForMultipleObjects(waitables, 0, timeout, win32event.QS_ALLEVENTS) if rc == win32event.WAIT_OBJECT_0 or rc == win32event.WAIT_TIMEOUT: while idle_queue: task = idle_queue.popleft() if not _execute_task(task): break elif rc == win32event.WAIT_OBJECT_0 + len(waitables): if pythoncom.PumpWaitingMessages(): break # wm_quit pythoncom.CoRevokeClassObject(revokeId) pythoncom.CoUninitialize()
def serve(clsid="{506e67c3-55b5-48c3-a035-eed5deea7d6d}"): """Launch the COM server, clsid is the XLPython object class id""" clsid = pywintypes.IID(clsid) # Override CreateInstance in default policy to instantiate the XLPython object --- BaseDefaultPolicy = win32com.server.policy.DefaultPolicy class MyPolicy(BaseDefaultPolicy): def _CreateInstance_(self, reqClsid, reqIID): if reqClsid == clsid: return serverutil.wrap(XLPython(), reqIID) else: return BaseDefaultPolicy._CreateInstance_(self, clsid, reqIID) win32com.server.policy.DefaultPolicy = MyPolicy # Create the class factory and register it factory = pythoncom.MakePyFactory(clsid) clsctx = pythoncom.CLSCTX_LOCAL_SERVER flags = pythoncom.REGCLS_MULTIPLEUSE | pythoncom.REGCLS_SUSPENDED revokeId = pythoncom.CoRegisterClassObject(clsid, factory, clsctx, flags) pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId()) pythoncom.CoResumeClassObjects() if not loop.is_running(): t = threading.Thread(target=_start_background_loop, daemon=True) t.start() tid = t.ident else: tid = None msg = "xlwings server running, clsid=%s, event loop on %s" logger.info(msg, clsid, tid) if logger.hasHandlers() else print(msg % (clsid, tid)) while True: rc = win32event.MsgWaitForMultipleObjects( (), 0, win32event.INFINITE, win32event.QS_ALLEVENTS ) if rc == win32event.WAIT_OBJECT_0: if pythoncom.PumpWaitingMessages(): break # wm_quit pythoncom.CoRevokeClassObject(revokeId) pythoncom.CoUninitialize()
l = [] for v in reversed(buffer(fmtid)): l.extend(1 if ((1 << j) & ord(v)) else 0 for j in reversed(range(8))) l.extend([0, 0]) print[hex(ord(i)) for i in buffer(fmtid)] print l for i in range(len(l) / 5): sublist = l[5 * i:5 * (i + 1)] number = sum(i * (1 << n) for (n, i) in enumerate(reversed(sublist))) print sublist, number, chars[number] desktop = shell.SHGetDesktopFolder() PyIShellFolder = type(desktop) PyIID = type(pywintypes.IID("{00000000-0000-0000-0000-000000000000}")) class ShellEntry(core._WinSysObject): def __init__(self, rpidl, parent=core.UNSET): self.parent = desktop if parent is core.UNSET else parent self.rpidl = rpidl def as_string(self): return self.parent.GetDisplayNameOf(self.rpidl) class ShellItem(ShellEntry): pass
def PackDEV_BROADCAST_DEVICEINTERFACE(classguid, name=""): rest_fmt = "16s%ds" % len(name) # str(buffer(iid)) hoops necessary to get the raw IID bytes. rest_data = (str(buffer(pywintypes.IID(classguid))), name) return PackDEV_BROADCAST(win32con.DBT_DEVTYP_DEVICEINTERFACE, rest_fmt, rest_data)
import sys import pythoncom import pywintypes import win32com.client import win32com.server.util as serverutil import win32com.server.dispatcher import win32com.server.policy import win32api import winerror # --- XLPython object class id --- clsid = pywintypes.IID(sys.argv[1]) # --- the XLPython class itself --- class XLPythonOption(object): def __init__(self, option, value): self.option = option self.value = value class XLPythonObject(object): _public_methods_ = ['Item', 'Count'] _public_attrs_ = ['_NewEnum'] def __init__(self, obj): self.obj = obj def _NewEnum(self):
try: import winreg except ImportError: # Python 2 import _winreg as winreg bytes = lambda x: str(buffer(x)) from ctypes import wintypes from win32com.shell import shell, shellcon from win32com.propsys import propsys, pscon # KNOWNFOLDERID # https://msdn.microsoft.com/en-us/library/dd378457 # win32com defines most of these, except the ones added in Windows 8. FOLDERID_AppsFolder = pywintypes.IID( "{1e87508d-89c2-42f0-8a7e-645a0f50ca58}") # win32com is missing SHGetKnownFolderIDList, so use ctypes. _ole32 = ctypes.OleDLL("ole32") _shell32 = ctypes.OleDLL("shell32") _REFKNOWNFOLDERID = ctypes.c_char_p _PPITEMIDLIST = ctypes.POINTER(ctypes.c_void_p) _ole32.CoTaskMemFree.restype = None _ole32.CoTaskMemFree.argtypes = (wintypes.LPVOID, ) _shell32.SHGetKnownFolderIDList.argtypes = ( _REFKNOWNFOLDERID, # rfid wintypes.DWORD, # dwFlags
def RegisterPythonServer(filename, progids=None, verbose=0): if progids: if isinstance(progids, str): progids = [progids] # we know the CLSIDs we need, but we might not be an admin user # and otherwise unable to register them. So as long as the progids # exist and the DLL points at our version, assume it already is. why_not = None for progid in progids: try: clsid = pywintypes.IID(progid) except pythoncom.com_error: # not registered. break try: HKCR = winreg.HKEY_CLASSES_ROOT hk = winreg.OpenKey(HKCR, "CLSID\\%s" % clsid) dll = winreg.QueryValue(hk, "InprocServer32") except WindowsError: # no CLSID or InProcServer32 - not registered break ok_files = [ os.path.basename(pythoncom.__file__), 'pythoncomloader%d%d.dll' % (sys.version_info[0], sys.version_info[1]) ] if os.path.basename(dll) not in ok_files: why_not = "%r is registered against a different Python version (%s)" % ( progid, dll) break else: #print "Skipping registration of '%s' - already registered" % filename return # needs registration - see if its likely! try: from win32com.shell.shell import IsUserAnAdmin except ImportError: print( "Can't import win32com.shell - no idea if you are an admin or not?" ) is_admin = False else: try: is_admin = IsUserAnAdmin() except pythoncom.com_error: # old, less-secure OS - assume *is* admin. is_admin = True if not is_admin: msg = "%r isn't registered, but I'm not an administrator who can register it." % progids[ 0] if why_not: msg += "\n(registration check failed as %s)" % why_not # throw a normal "class not registered" exception - we don't report # them the same way as "real" errors. raise pythoncom.com_error(winerror.CO_E_CLASSSTRING, msg, None, -1) # so theoretically we are able to register it. cmd = '%s "%s" --unattended > nul 2>&1' % (win32api.GetModuleFileName(0), filename) if verbose: print("Registering engine", filename) # print cmd rc = os.system(cmd) if rc: print("Registration command was:") print(cmd) raise RuntimeError("Registration of engine '%s' failed" % filename)
def is_range_instance(xl_range): pyid = getattr(xl_range, '_oleobj_', None) if pyid is None: return False return xl_range._oleobj_.GetTypeInfo().GetTypeAttr().iid == pywintypes.IID( '{00020846-0000-0000-C000-000000000046}')
def testGUIDInDict(self): s = "{00020400-0000-0000-C000-000000000046}" iid = pywintypes.IID(s) d = dict(item=iid) assert d['item'] == iid
FILE_PREFETCH_TYPE_MAX = 4 FILESYSTEM_STATISTICS_TYPE_NTFS = 1 FILESYSTEM_STATISTICS_TYPE_FAT = 2 FILE_SET_ENCRYPTION = 0x00000001 FILE_CLEAR_ENCRYPTION = 0x00000002 STREAM_SET_ENCRYPTION = 0x00000003 STREAM_CLEAR_ENCRYPTION = 0x00000004 MAXIMUM_ENCRYPTION_VALUE = 0x00000004 ENCRYPTION_FORMAT_DEFAULT = 0x01 COMPRESSION_FORMAT_SPARSE = 0x4000 COPYFILE_SIS_LINK = 0x0001 COPYFILE_SIS_REPLACE = 0x0002 COPYFILE_SIS_FLAGS = 0x0003 WMI_DISK_GEOMETRY_GUID = pywintypes.IID("{25007F51-57C2-11D1-A528-00A0C9062910}") GUID_DEVINTERFACE_CDROM = pywintypes.IID("{53F56308-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_FLOPPY = pywintypes.IID("{53F56311-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR = pywintypes.IID("{4D36E978-E325-11CE-BFC1-08002BE10318}") GUID_DEVINTERFACE_COMPORT = pywintypes.IID("{86E0D1E0-8089-11D0-9CE4-08003E301F73}") GUID_DEVINTERFACE_DISK = pywintypes.IID("{53F56307-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_STORAGEPORT = pywintypes.IID("{2ACCFE60-C130-11D2-B082-00A0C91EFB8B}") GUID_DEVINTERFACE_CDCHANGER = pywintypes.IID("{53F56312-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_PARTITION = pywintypes.IID("{53F5630A-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_VOLUME = pywintypes.IID("{53F5630D-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_WRITEONCEDISK = pywintypes.IID("{53F5630C-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_TAPE = pywintypes.IID("{53F5630B-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_MEDIUMCHANGER = pywintypes.IID("{53F56310-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_SERENUM_BUS_ENUMERATOR = GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR GUID_CLASS_COMPORT = GUID_DEVINTERFACE_COMPORT
def testGUIDInDict(self): s = "{00020400-0000-0000-C000-000000000046}" iid = pywintypes.IID(s) d = dict(item=iid) self.failUnlessEqual(d['item'], iid)
def _guid_from_buffer(b): return pywintypes.IID(b, True)