def portiter():
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, b'HARDWARE\\DEVICEMAP\\SERIALCOMM') # open the registry
i = 0
while True: # loop until we run out of devices
try:
name = bytes(winreg.EnumValue(key, i)[1]) # get the device name
# EnumValue gets item number i, returning a tuple containing the name in position 1
except OSError: # that's all the devices
break
yield name, port_prefix + name
i += 1
评论列表
文章目录