-
Notifications
You must be signed in to change notification settings - Fork 668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When creating explorer favorite use more specific windows functions #5690
Merged
jturcotte
merged 8 commits into
owncloud:master
from
remixtj:utility_SHGetKnownFolderPath
Apr 27, 2017
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
130d280
When creating explorer favorite use more specific windows functions
remixtj c4b5b78
When creating explorer favorite use more specific windows functions
remixtj 42371c8
When creating explorer favorite use more specific windows functions
remixtj 9cf6776
When creating explorer favorite use more specific windows functions
remixtj 9df6dff
When creating explorer favorite use more specific windows functions
remixtj a836759
When creating explorer favorite use more specific windows functions
remixtj f1b449a
When creating explorer favorite use more specific windows functions
remixtj 3307aee
When creating explorer favorite use more specific windows functions
remixtj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,21 +15,36 @@ | |
#include <shlobj.h> | ||
#include <winbase.h> | ||
#include <windows.h> | ||
#include <shlguid.h> | ||
#include <string> | ||
#include <QLibrary> | ||
|
||
static const char runPathC[] = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"; | ||
|
||
|
||
|
||
static void setupFavLink_private(const QString &folder) | ||
{ | ||
// Windows Explorer: Place under "Favorites" (Links) | ||
wchar_t path[MAX_PATH]; | ||
SHGetSpecialFolderPath(0, path, CSIDL_PROFILE, FALSE); | ||
QString profile = QDir::fromNativeSeparators(QString::fromWCharArray(path)); | ||
|
||
QString linkName; | ||
QDir folderDir(QDir::fromNativeSeparators(folder)); | ||
QString linkName = profile+QLatin1String("/Links/") + folderDir.dirName() + QLatin1String(".lnk"); | ||
|
||
/* Use new WINAPI functions */ | ||
PWSTR path; | ||
|
||
if(SHGetKnownFolderPath(FOLDERID_Links, 0, NULL, &path) == S_OK) { | ||
QString links = QDir::fromNativeSeparators(QString::fromWCharArray(path)); | ||
linkName = QDir(links).filePath(folderDir.dirName() + QLatin1String(".lnk")); | ||
} | ||
qDebug() << Q_FUNC_INFO << " creating link from " << linkName << " to " << folder; | ||
CoTaskMemFree(path); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will crash if path is not null and yet not pointing to a valid allocation, which can happen if |
||
if (!QFile::link(folder, linkName)) | ||
qDebug() << Q_FUNC_INFO << "linking" << folder << "to" << linkName << "failed!"; | ||
|
||
} | ||
|
||
|
||
bool hasLaunchOnStartup_private(const QString &appName) | ||
{ | ||
QString runPath = QLatin1String(runPathC); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the documentation about the
path
argument:Could you verify or fix it?