这个相对简单多了,只是练习注册表操作而已
?
import winreg,sys
def full_screen():
key_str=r"SYSTEMCurrentControlSetHardware ProfilesUnitedVideoCONTROLVIDEO"
try:
key=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,key_str)
except FileNotFoundError:
pass
sys.exit()
#取第一个子键的名字
name= winreg.EnumKey(key,0)
#再进入两级子键取健值
‘‘‘HKEY_LOCAL_MACHINESYSTEMCurrentControlSetHardware Profiles
UnitedVideoCONTROLVIDEO{D8248518-C844-4ACD-B85B-38CD0BAACADB} 000‘‘‘
key_str2=key_str+‘‘+name+‘ 000‘
#取指定项的值(当前分辨率)
key=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,key_str2)
scr_x,x_value_type= winreg.QueryValueEx(key,‘DefaultSettings.XResolution‘)
scr_y,y_value_type= winreg.QueryValueEx(key,‘DefaultSettings.YResolution‘)
return (scr_x,scr_y)
print(full_screen())