Debian Codegraph @

plyer/platforms/win/uniqueid.py

raw symbols SCIP
1 '''
2 Module of Windows API for plyer.uniqueid.
3 '''
4
5 try:
6 import _winreg as regedit
7 except ImportError:
8 try:
9 import winreg as regedit
10 except ImportError:
11 raise NotImplementedError()
12
13 from plyer.facades import UniqueID
14
15
16 class WinUniqueID(UniqueID):
17 '''
18 Implementation of Windows battery API.
19 '''
20
21 def _get_uid(self):
22 # Win XP+, REG QUERY KEY /V VALUE, case-insensitive
23 handle = regedit.OpenKey(
24 regedit.HKEY_LOCAL_MACHINE,
25 r"SOFTWARE\\Microsoft\\Cryptography", 0,
26 regedit.KEY_READ | regedit.KEY_WOW64_64KEY
27 )
28 value, _ = regedit.QueryValueEx(handle, "MachineGuid")
29 return value
30
31
32 def instance():
33 '''
34 Instance for facade proxy.
35 '''
36 return WinUniqueID()