Sideband/sbapp/plyer/platforms/win/uniqueid.py

37 lines
791 B
Python
Raw Normal View History

2022-09-16 12:07:57 -04:00
'''
Module of Windows API for plyer.uniqueid.
'''
try:
import _winreg as regedit
except ImportError:
try:
import winreg as regedit
except ImportError:
raise NotImplementedError()
2024-06-02 12:31:58 -04:00
from sbapp.plyer.facades import UniqueID
2022-09-16 12:07:57 -04:00
class WinUniqueID(UniqueID):
'''
Implementation of Windows battery API.
'''
def _get_uid(self):
# Win XP+, REG QUERY KEY /V VALUE, case-insensitive
handle = regedit.OpenKey(
regedit.HKEY_LOCAL_MACHINE,
r"SOFTWARE\\Microsoft\\Cryptography", 0,
regedit.KEY_READ | regedit.KEY_WOW64_64KEY
)
value, _ = regedit.QueryValueEx(handle, "MachineGuid")
return value
def instance():
'''
Instance for facade proxy.
'''
return WinUniqueID()