diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2010-01-07 17:46:16 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-01-11 12:56:56 (GMT) |
commit | 579b9f70d10ba66e7fce83c4b693377768f7352a (patch) | |
tree | 3b8e4d406be1e53802ba96b4641b59e80d5e3108 | |
parent | 7c2193617d3631432ee7c3265aa1482b19721773 (diff) | |
download | Qt-579b9f70d10ba66e7fce83c4b693377768f7352a.zip Qt-579b9f70d10ba66e7fce83c4b693377768f7352a.tar.gz Qt-579b9f70d10ba66e7fce83c4b693377768f7352a.tar.bz2 |
Enable building with MSVC2008
Removed the alternate implementation of the registry reading, although
the new API is simpler, the old XP method is not deprecated.
Added an extra library that is needed according to API documentation,
but is omittable on MinGW.
Also gave a better error message when serial port detection fails.
Reviewed-by: Miikka Heikkinen
(cherry picked from commit 32419380bdd11e7db401fd37a840e0ec4f5b6845)
-rw-r--r-- | tools/runonphone/main.cpp | 4 | ||||
-rw-r--r-- | tools/runonphone/runonphone.pro | 3 | ||||
-rw-r--r-- | tools/runonphone/serenum_win.cpp | 11 |
3 files changed, 7 insertions, 11 deletions
diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index dae4438..98f7f2d 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -122,6 +122,10 @@ int main(int argc, char *argv[]) serialPortName = id.portName; } } + if(serialPortName.isEmpty()) { + errstream << "No phone found, ensure USB cable is connected or specify manually with -p" << endl; + return 1; + } } QScopedPointer<trk::Launcher> launcher; diff --git a/tools/runonphone/runonphone.pro b/tools/runonphone/runonphone.pro index d243121..cf0c055 100644 --- a/tools/runonphone/runonphone.pro +++ b/tools/runonphone/runonphone.pro @@ -15,5 +15,6 @@ HEADERS += trksignalhandler.h \ windows { SOURCES += serenum_win.cpp LIBS += -lsetupapi \ - -luuid + -luuid \ + -ladvapi32 } diff --git a/tools/runonphone/serenum_win.cpp b/tools/runonphone/serenum_win.cpp index 82bf7c9..f99462c 100644 --- a/tools/runonphone/serenum_win.cpp +++ b/tools/runonphone/serenum_win.cpp @@ -77,8 +77,7 @@ QList<SerialPortId> enumerateSerialPorts() } HKEY key = SetupDiOpenDevRegKey(infoset, &info, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ); if(key != INVALID_HANDLE_VALUE) { -#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600 - //RegGetValue not supported on XP, SHRegGetValue not supported by mingw :( + //RegGetValue not supported on XP, SHRegGetValue not supported by mingw, so use the old method of enumerating all the values for (DWORD dwi=0;;dwi++) { DWORD vsize = valueName.size(); if (ERROR_SUCCESS == RegEnumValue(key, dwi, (WCHAR*)(valueName.data()), &vsize, 0, 0, 0, &size)) { @@ -93,14 +92,6 @@ QList<SerialPortId> enumerateSerialPorts() break; } } -#else - if (ERROR_SUCCESS == SHRegGetValue(key, 0, "PortName", SRRF_RT_REG_SZ, 0, &size)) { - QByteArray ba(size, 0); - if (ERROR_SUCCESS == RegGetValue(key, 0, "PortName", SRRF_RT_REG_SZ, (BYTE*)(ba.data()), &size)) { - portName = QString((const QChar*)(ba.constData()), ba.size() / 2 - 1); - } - } -#endif RegCloseKey(key); } SerialPortId id; |