Read the key values in the registry in Python as follows:
#coding:utf-8
import win32api, win32con
import os
key = win32api.RegOpenKeyEx(win32con.HKEY_CLASSES_ROOT, 'CLSID\\{01249E9F-88FF-45d5-82DB-A1BEE06E123C}\\Shell\Open\\Command', 0, win32con.KEY_READ)
keyValue = win32api.RegQueryValue(key, '')
print keyValue
Then run it with the following error:
Traceback (most recent call last): File "D:\users\Desktop\yunpanAuto.py", line 8, in <module> key = win32api.RegOpenKeyEx(win32con.HKEY_CLASSES_ROOT, 'CLSID\\{01249E9F-88FF-45d5-82DB-A1BEE06E123C}\\Shell\Open\\Command', 0, win32con.KEY_READ) error: (2, 'RegOpenKeyEx', '\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xce\xc4\xbc\xfe\xa1\xa3')
This depends on my own problem, because my Window system is 64-bit and Python is 32-bit, so I need to add another parameter:
key = win32api.RegOpenKeyEx(win32con.HKEY_CLASSES_ROOT, 'CLSID\\{01249E9F-88FF-45d5-82DB-A1BEE06E123C}\\Shell\Open\\Command', 0, win32con.KEY_READ | win32con.KEY_WOW64_64KEY)
Just change the statement after the key above.
Read More:
- Unable to find VBScript script engine or error 2738, could not access VBScript runtime
- ImportError: ‘DLL load failed: %1 is not a valid Win32 application.
- RegOpenKeyEx returns error value 5
- Win10, add sublime text in the right mouse button menu to open
- An I/O operation initiated by the Registry failed unrecoverably
- Delete the specified crontab timer task under Linux
- Win10 can’t drag files to open directly
- Solution to the error code of 0x80040154 in COM / ole call
- putty Network error:Software caused Connection abort solution – measured valid
- The method of getting shell command output in Python
- Shell script: syntax error: bad for loop variable error resolution
- Global variable error: unboundlocalerror: local variable ‘l’ referenced before assignment
- Lookuperror: unknown encoding: cp65001 when executing Python
- MDK (keil) debugging often appears flashback phenomenon solution.
- Reset power on password of lightning simulator
- Error 1606 could not access network location% SystemDrive% / inetpub / wwwroot /
- Error 1606 Could Not Access Network Location %SystemDrive%/inetpub/wwwroot/
- Python – [encoding] in Python os.system Solution to Chinese garbled code when calling CMD command
- Boot nginx flash back under Windows
- From in Python__ future__ The role of import *