From 18c916517f3004d34482c20ed66bf09ec274d385 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 2 Jan 2013 16:50:06 +0100 Subject: [PATCH] Use backslashes for UNC paths. ShellExecute fails to open a share folder due to using '/' instead of '\'. Windows API doesn't support forward slashes for extended-length path. Extended-length path are path that start with a "\\?\" prefix. For example, "\\?\c:\very_long_path\foo\bar.txt", or in the case of a UNC path that would be "\\?\very_long_path\foo\bar.txt". [1] [1] http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maxpath Task-number: QTBUG-13359 Change-Id: Ibb113abeebd56f106f76520bc23dba797de548fa Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsservices.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp index 3121d5c869..cd446efc62 100644 --- a/src/plugins/platforms/windows/qwindowsservices.cpp +++ b/src/plugins/platforms/windows/qwindowsservices.cpp @@ -44,6 +44,7 @@ #include #include +#include #include #ifndef Q_OS_WINCE @@ -57,7 +58,8 @@ enum { debug = 0 }; static inline bool shellExecute(const QString &file) { #ifndef Q_OS_WINCE - const quintptr result = (quintptr)ShellExecute(0, 0, (wchar_t*)file.utf16(), 0, 0, SW_SHOWNORMAL); + const QString nativeFilePath = QDir::toNativeSeparators(file); + const quintptr result = (quintptr)ShellExecute(0, 0, (wchar_t*)nativeFilePath.utf16(), 0, 0, SW_SHOWNORMAL); // ShellExecute returns a value greater than 32 if successful if (result <= 32) { qWarning("ShellExecute '%s' failed (error %s).", qPrintable(file), qPrintable(QString::number(result)));