def create(self, path): """ Creates a new Registry key. @type path: str @param path: Registry key path. @rtype: L{RegistryKey} @return: The newly created Registry key. """ path = self._sanitize_path(path) hive, subpath = self._parse_path(path) handle = win32.RegCreateKey(hive, subpath) return RegistryKey(path, handle)
def __setitem__(self, path, value): do_copy = isinstance(value, RegistryKey) if not do_copy and not isinstance(value, str) \ and not isinstance(value, compat.unicode): if isinstance(value, object): t = value.__class__.__name__ else: t = type(value) raise TypeError("Expected string or RegistryKey, got %s" % t) hive, subpath = self._parse_path(path) with win32.RegCreateKey(hive, subpath) as handle: if do_copy: win32.RegCopyTree(value.handle, None, handle) else: win32.RegSetValueEx(handle, None, value)