diff options
author | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2009-08-06 00:33:48 +0000 |
---|---|---|
committer | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2009-08-06 00:33:48 +0000 |
commit | 4ecac5ecd82acbbe59ef58eb9240ee5685f06eb2 (patch) | |
tree | 80be63c517e7edb5a0e3808fd1a42619d142fc89 /examples | |
parent | 15d21ebd9316e8c813c6dfe45d344edefcb10970 (diff) | |
download | pyserial-4ecac5ecd82acbbe59ef58eb9240ee5685f06eb2.tar.gz |
fix the fix
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@308 f19166aa-fa4f-0410-85c2-fa1106f25c8a
Diffstat (limited to 'examples')
-rw-r--r-- | examples/scanwin32.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/examples/scanwin32.py b/examples/scanwin32.py index aec5bb0..13cad47 100644 --- a/examples/scanwin32.py +++ b/examples/scanwin32.py @@ -95,6 +95,7 @@ INVALID_HANDLE_VALUE = 0 ERROR_INSUFFICIENT_BUFFER = 122 SPDRP_HARDWAREID = 1 SPDRP_FRIENDLYNAME = 12 +SPDRP_LOCATION_INFORMATION = 13 ERROR_NO_MORE_ITEMS = 259 def comports(available_only=True): @@ -178,12 +179,20 @@ def comports(available_only=True): # Ignore ERROR_INSUFFICIENT_BUFFER if ctypes.GetLastError() != ERROR_INSUFFICIENT_BUFFER: #~ raise ctypes.WinError() - # not getting friendly name for com0com devices -> skip it - continue + # not getting friendly name for com0com devices, try something else + szFriendlyName = ctypes.create_string_buffer(1024) + SetupDiGetDeviceRegistryProperty( + g_hdi, + ctypes.byref(devinfo), + SPDRP_LOCATION_INFORMATION, + None, + ctypes.byref(szFriendlyName), ctypes.sizeof(szFriendlyName) - 1, + None + ) try: port_name = re.search(r"\((.*)\)", szFriendlyName.value).group(1) except AttributeError, msg: - pass + port_name = szFriendlyName.value yield port_name, szFriendlyName.value, szHardwareID.value SetupDiDestroyDeviceInfoList(g_hdi) |