Question: Please write in Python 2.7. Write a program that takes a value from a user and stores it in the registry. You can use any
Please write in Python 2.7.
Write a program that takes a value from a user and stores it in the registry. You can use any key name that you like but also store the current time as another value inside of your new key. Finally, get a directory listing of your current working directory and store that value. You may need to use REG_MULTI_SZ for that value.
I'm having alot of trouble and would really appreciate some assistance. This is what I've got so far:
import _winreg import sys import os import datetime REGISTRY_PATH = r"USER\my_program\Settings" def set_register(key_name, value): try: _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, REGISTRY_PATH) registry_key= _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, REGISTRY_PATH, 0, _winreg.KEY_WRITE) _winreg.SetValueEx(registry_key, key_name, 0, _winreg.REG_SZ, value) _winreg.SetValueEx(registry_key, key_name, 0, _winreg.REG_SZ, datetime.datetime.now()) _winreg.CloseKey(registry_key) return True except WindowsError: return False name = input("Enter key name: ") set_register('Ralph', name);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
