5#include <QtCore/qt_windows.h>
7#include <QtCore/qurl.h>
8#include <QtCore/qdebug.h>
9#include <QtCore/qdir.h>
10#include <QtCore/qscopedpointer.h>
11#include <QtCore/qthread.h>
13#include <QtCore/private/qwinregistry_p.h>
14#include <QtCore/private/qfunctions_win_p.h>
30 const wchar_t *parameters)
31 : m_operation(operation)
33 , m_parameters(parameters) { }
38 if (comHelper.isValid())
39 m_result = ShellExecute(
nullptr, m_operation, m_file, m_parameters,
nullptr,
43 HINSTANCE
result()
const {
return m_result; }
46 HINSTANCE m_result =
nullptr;
47 const wchar_t *m_operation;
48 const wchar_t *m_file;
49 const wchar_t *m_parameters;
64 WCHAR browserExecutable[
MAX_PATH] = {};
65 const wchar_t operation[] = L
"open";
66 DWORD browserExecutableSize =
MAX_PATH;
67 if (FAILED(AssocQueryString(0, ASSOCSTR_EXECUTABLE, L
"http", operation,
68 browserExecutable, &browserExecutableSize))) {
74 browser =
"msedge.exe"_L1;
80 reinterpret_cast<const wchar_t *
>(browser.
utf16()),
81 reinterpret_cast<const wchar_t *
>(urlS.
utf16()));
106 reinterpret_cast<const wchar_t *
>(nativeFilePath.
utf16()),
128 const wchar_t mailUserKey[] = L
"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice";
134 keyName += mailto +
"\\Shell\\Open\\Command"_L1;
144 wchar_t expandedCommand[
MAX_PATH] = {0};
145 return ExpandEnvironmentStrings(
reinterpret_cast<const wchar_t *
>(command.
utf16()),
158 const QChar doubleQuote = u
'"';
161 if (exeIndex != -1) {
162 command.
insert(exeIndex + 4, doubleQuote);
170 qDebug() << __FUNCTION__ <<
"Launching" << command;
172 PROCESS_INFORMATION
pi;
173 ZeroMemory(&
pi,
sizeof(
pi));
175 ZeroMemory(&si,
sizeof(si));
177 if (!CreateProcess(
nullptr,
reinterpret_cast<wchar_t *
>(
const_cast<ushort *
>(command.
utf16())),
178 nullptr,
nullptr, FALSE, 0,
nullptr,
nullptr, &si, &
pi)) {
182 CloseHandle(
pi.hProcess);
183 CloseHandle(
pi.hThread);
static QString toNativeSeparators(const QString &pathName)
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString & replace(qsizetype i, qsizetype len, QChar after)
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString & insert(qsizetype i, QChar c)
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString & prepend(QChar c)
void start(Priority=InheritPriority)
bool wait(QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
QString scheme() const
Returns the scheme of the URL.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
QString stringValue(QStringView subKey) const
bool openUrl(const QUrl &url) override
bool openDocument(const QUrl &url) override
QWindowsShellExecuteThread(const wchar_t *operation, const wchar_t *file, const wchar_t *parameters)
void qErrnoWarning(const char *msg,...)
Combined button and popup list for selecting options.
static constexpr int BufferSize
static QString keyName(const QString &rKey)
#define qPrintable(string)
#define qUtf16Printable(string)
#define QStringLiteral(str)
static bool launchMail(const QUrl &url)
static QString msgShellExecuteFailed(const QUrl &url, quintptr code)
static QString mailCommand()
static bool shellExecute(const QUrl &url)
static bool openWebBrowser(const QUrl &url)
QUrl url("example.com")
[constructor-url-reference]