diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/file_util.h | 8 | ||||
-rw-r--r-- | base/file_util_win.cc | 20 |
2 files changed, 28 insertions, 0 deletions
diff --git a/base/file_util.h b/base/file_util.h index 782a6a2..c86e6e4 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -237,6 +237,14 @@ bool UpdateShortcutLink(const wchar_t *source, const wchar_t *destination, const wchar_t *description, const wchar_t *icon, int icon_index); +// Pins a shortcut to the Windows 7 taskbar. The shortcut file must already +// exist and be a shortcut that points to an executable. +bool TaskbarPinShortcutLink(const wchar_t* shortcut); + +// Unpins a shortcut from the Windows 7 taskbar. The shortcut must exist and +// already be pinned to the taskbar. +bool TaskbarUnpinShortcutLink(const wchar_t* shortcut); + // Return true if the given directory is empty bool IsDirectoryEmpty(const std::wstring& dir_path); diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 3105d37..e050324 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -413,6 +413,26 @@ bool UpdateShortcutLink(const wchar_t *source, const wchar_t *destination, return SUCCEEDED(result); } +bool TaskbarPinShortcutLink(const wchar_t* shortcut) { + // "Pin to taskbar" is only supported after Win7. + if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) + return false; + + int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarpin", shortcut, + NULL, NULL, 0)); + return result > 32; +} + +bool TaskbarUnpinShortcutLink(const wchar_t* shortcut) { + // "Unpin from taskbar" is only supported after Win7. + if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) + return false; + + int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarunpin", + shortcut, NULL, NULL, 0)); + return result > 32; +} + bool IsDirectoryEmpty(const std::wstring& dir_path) { FileEnumerator files(FilePath(dir_path), false, static_cast<FileEnumerator::FILE_TYPE>( |