From 4ecac5ecd82acbbe59ef58eb9240ee5685f06eb2 Mon Sep 17 00:00:00 2001 From: cliechti Date: Thu, 6 Aug 2009 00:33:48 +0000 Subject: fix the fix git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@308 f19166aa-fa4f-0410-85c2-fa1106f25c8a --- examples/scanwin32.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'examples') 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) -- cgit v1.2.1