summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2013-04-12 23:25:28 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-20 23:57:18 +0200
commit3bfe998860e0bfd3ce48784188eaa0d58bf86da1 (patch)
tree70b4e3ef079fb8146728c91c811f7531515d1ca0
parente503daff92735e9f7df7493ffb1b3526005eb07d (diff)
downloadqtserialport-3bfe998860e0bfd3ce48784188eaa0d58bf86da1.tar.gz
Refactor the Windows port enumeration from GUID classes to devinterfaces
Earlier enumeration of devices was made through GUID classes. But MSDN says that this approach became outdated (since Windows 2000), and instead of classes it is necessary to use GUID interfaces. See: * http://msdn.microsoft.com/en-us/library/windows/hardware/ff545036%28v=vs.85%29.aspx * http://msdn.microsoft.com/en-us/library/windows/hardware/ff545046%28v=vs.85%29.aspx Thus there was a changeover of: * GUID_DEVCLASS_PORTS by GUID_DEVINTERFACE_COMPORT * GUID_CLASS_MODEM by GUID_DEVINTERFACE_MODEM Of course, flags for the SetupDiGetClassDevs() function changed also. This approach decided the following: * Use of newer API for enumeration * There is no need GUID classes for non-standard "purely" the virtual devices (like com0com and so forth) * There is no need to check for name "LPT" existence, because GUID_DEVINTERFACE_COMPORT belong only to serial ports devices (instead of GUID_DEVCLASS_PORTS that include serial and parallel ports). It is checked on devices: * Built-in serial ports * USB/Serial converters (PL, FTDI) * USB Bluetooth serial ports (with standard MS stack) * USB modems (ZTE MF180) * Com0com virtual serial ports * Eltima virtual serial ports * Telit virtual serial ports It is checked on OS: Windows XP/Vista/7/8 Change-Id: I9da51d815ac5081a95113659be2b38ebd31275a4 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Laszlo Papp <lpapp@kde.org>
-rw-r--r--src/serialport/qserialportinfo_win.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/serialport/qserialportinfo_win.cpp b/src/serialport/qserialportinfo_win.cpp
index 7ca1f5e..3299936 100644
--- a/src/serialport/qserialportinfo_win.cpp
+++ b/src/serialport/qserialportinfo_win.cpp
@@ -59,16 +59,10 @@ QT_BEGIN_NAMESPACE
static const GUID guidsArray[] =
{
- // Windows Ports Class GUID
- { 0x4D36E978, 0xE325, 0x11CE, { 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18 } },
- // Virtual Ports Class GUID (i.e. com0com and etc)
- { 0xDF799E12, 0x3C56, 0x421B, { 0xB2, 0x98, 0xB6, 0xD3, 0x64, 0x2B, 0xC8, 0x78 } },
- // Windows Modems Class GUID
- { 0x4D36E96D, 0xE325, 0x11CE, { 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18 } },
- // Eltima Virtual Serial Port Driver v4 GUID
- { 0xCC0EF009, 0xB820, 0x42F4, { 0x95, 0xA9, 0x9B, 0xFA, 0x6A, 0x5A, 0xB7, 0xAB } },
- // Advanced Virtual COM Port GUID
- { 0x9341CD95, 0x4371, 0x4A37, { 0xA5, 0xAF, 0xFD, 0xB0, 0xA9, 0xD1, 0x96, 0x31 } },
+ // GUID_DEVINTERFACE_COMPORT
+ { 0x86E0D1E0, 0x8089, 0x11D0, { 0x9C, 0xE4, 0x08, 0x00, 0x3E, 0x30, 0x1F, 0x73} },
+ // GUID_DEVINTERFACE_MODEM
+ { 0x2C7089AA, 0x2E0E, 0x11D1, { 0xB1, 0x14, 0x00, 0xC0, 0x4F, 0xC2, 0xAA, 0xE4} },
};
static QVariant deviceRegistryProperty(HDEVINFO deviceInfoSet,
@@ -151,7 +145,8 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
static const int guidCount = sizeof(guidsArray)/sizeof(guidsArray[0]);
for (int i = 0; i < guidCount; ++i) {
- const HDEVINFO deviceInfoSet = ::SetupDiGetClassDevs(&guidsArray[i], NULL, 0, DIGCF_PRESENT);
+ const HDEVINFO deviceInfoSet = ::SetupDiGetClassDevs(&guidsArray[i], NULL, 0,
+ DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (deviceInfoSet == INVALID_HANDLE_VALUE)
return serialPortInfoList;
@@ -164,7 +159,7 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
QSerialPortInfo serialPortInfo;
QString s = devicePortName(deviceInfoSet, &deviceInfoData);
- if (s.isEmpty() || s.contains(QLatin1String("LPT")))
+ if (s.isEmpty())
continue;
serialPortInfo.d_ptr->portName = s;