-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample code to create and read keys from Windows registries
- Loading branch information
Showing
2 changed files
with
18 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import _winreg as wreg | ||
# Create new registry key with subkey and new value - Reenable next 3 lines when this code is run for the first time | ||
#key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE, "Software\\TestCompany\\TestProject") | ||
#wreg.SetValue(key, 'NewSubkey', wreg.REG_SZ, 'testsubkey') | ||
#wreg.SetValueEx(key, 'ValueName', 0, wreg.REG_SZ, 'testvalue') | ||
|
||
key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE, "Software\\TestCompany\\TestProject",0, wreg.KEY_ALL_ACCESS) | ||
print ("Next line should output: testsubkey") | ||
print (wreg.QueryValue(key, 'NewSubkey')) | ||
print ("Next line should output: testvalue") | ||
print (wreg.QueryValueEx(key, 'ValueName')) | ||
key.Close() |