def writeRegKey(self, keyname):
		"""Writes configuration data to the registry key"""
		kkey = CreateKey(HKEY_LOCAL_MACHINE, keyname)		
		kkey.Close()
		kkey = OpenKey(HKEY_LOCAL_MACHINE, keyname, 0, KEY_ALL_ACCESS)	
		# Clean out default values and keys
		kinfo = QueryInfoKey(kkey)
		for x in range(0, kinfo[1]):
			try:
				(name, value, ttype) = EnumValue(kkey, x)
				DeleteValue(kkey, name)
			except EnvironmentError:
				break
		for x in range(0, kinfo[0]):
			try:
				subname = EnumKey(kkey, x)
				DeleteKey(kkey, subname)
			except EnvironmentError:
				break

		# Writing defaults
		defaults = self.defaults()
		for defname in defaults.keys():
			SetValueEx(kkey, defname, 0, REG_SZ, defaults[defname])

		# Creating keys with options
		sections = self.sections()
		for sect in sections:
			subname = keyname + "\\" + sect
			sub_key = CreateKey(HKEY_LOCAL_MACHINE, subname)
			sub_key.Close()
			sub_key = OpenKey(HKEY_LOCAL_MACHINE, subname, 0, KEY_SET_VALUE)
			opts = self.options(sect)
			for opt in opts:
				SetValueEx(sub_key, opt, 0, REG_SZ, self.get(sect, opt))
			sub_key.Close()

		kkey.Close()
		pass
Writes configuration data to the registry key
recipes/Python/138944_Extending_ConfigParser_reading_writing_options/recipe-138944.py