Play With Windows Registry using Python
Code Example Note **: Only For Windows User Suppose we are creating one windows application and that has some license key for what is the best place to keep that key so that no can hack it or reuse it. Let's start ..... We will be creating a Function for a different purpose Example : # test.py import winreg as wreg def store_data_in_windows_registry(): my_key = "my-demo-key" data = "Test data" key = wreg.CreateKey(wreg.HKEY_CURRENT_USER, my_key) wreg.SetValue(key, my_key, wreg.REG_SZ, data) print("Data Set in Register") def get_data_from_windows_registry(): my_key = "my-demo-key" try: key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, my_key) return wreg.QueryValue(key, my_key) except: return "No Data Found" def clear_data_from_windows_registry(): my_key = "my-demo-key" key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, my_key) try: wreg.DeleteKey(key, my_key)