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 <Friedemann.Kleint@digia.com>
This commit is contained in:
Gatis Paeglis 2013-01-02 16:50:06 +01:00 committed by The Qt Project
parent d4adcfb8cc
commit 18c916517f

View File

@ -44,6 +44,7 @@
#include <QtCore/QUrl>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <shlobj.h>
#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)));