Bonjour tout le monde!

Je n'arrive pas à utiliser winreg.loadkey()...
Et ce malgré avoir lu la documentation officielle disponible ici:
https://docs.python.org/3/library/winreg.html

J'arrive à sauvegarder mes clés de registre avec winreg.savekey() cependant...

Concrètement "ExportRegistryKey()" fonctionne mais pas "LoadRegistryKey()"
Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
    def ExportRegistryKey(RegisterRoot, Key, Name):
        priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
        hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess (), priv_flags)
        backup_privilege_id = win32security.LookupPrivilegeValue (None, "SeBackupPrivilege")
        restore_privilege_id = win32security.LookupPrivilegeValue (None, "SeRestorePrivilege")
        win32security.AdjustTokenPrivileges (
            hToken, 0, [
            (backup_privilege_id, win32security.SE_PRIVILEGE_ENABLED),
            (restore_privilege_id, win32security.SE_PRIVILEGE_ENABLED)
            ]
        )
        key         = winreg.OpenKey(RegisterRoot, Key+'\\'+Name)
        Destination = "D:\\Backup\\"+Name+"\\"
        ...
        winreg.SaveKey(key, Destination+"\\"+Name) # On sauvegarde sans extension comme le dit la doc!
 
    def LoadRegistryKey(RegisterRoot, Key, Name):
        priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
        hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess (), priv_flags)
        backup_privilege_id = win32security.LookupPrivilegeValue (None, "SeBackupPrivilege")
        restore_privilege_id = win32security.LookupPrivilegeValue (None, "SeRestorePrivilege")
        win32security.AdjustTokenPrivileges (
            hToken, 0, [
            (backup_privilege_id, win32security.SE_PRIVILEGE_ENABLED),
            (restore_privilege_id, win32security.SE_PRIVILEGE_ENABLED)
            ]
        )
 
        key         = winreg.OpenKey(RegisterRoot, Key+'\\'+Name)
        Destination = "D:\\Backup\\"+Name+"\\"+Name  # On charge la sauvegarde sans extension comme le dit la doc!
        if os.path.exists(Destination):
            winreg.LoadKey(RegisterRoot, Key, Destination)
        ...
Merci pour votre aide!