123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- #ifndef BASE_WIN_SHORTCUT_H_
- #define BASE_WIN_SHORTCUT_H_
- #include <windows.h>
- #include <stdint.h>
- #include "base/base_export.h"
- #include "base/check.h"
- #include "base/files/file_path.h"
- namespace base {
- namespace win {
- enum ShortcutOperation {
-
- SHORTCUT_CREATE_ALWAYS = 0,
-
-
-
- SHORTCUT_REPLACE_EXISTING,
-
- SHORTCUT_UPDATE_EXISTING,
- };
- struct BASE_EXPORT ShortcutProperties {
- enum IndividualProperties {
- PROPERTIES_TARGET = 1U << 0,
- PROPERTIES_WORKING_DIR = 1U << 1,
- PROPERTIES_ARGUMENTS = 1U << 2,
- PROPERTIES_DESCRIPTION = 1U << 3,
- PROPERTIES_ICON = 1U << 4,
- PROPERTIES_APP_ID = 1U << 5,
- PROPERTIES_DUAL_MODE = 1U << 6,
- PROPERTIES_TOAST_ACTIVATOR_CLSID = 1U << 7,
-
- PROPERTIES_ALL = PROPERTIES_TARGET | PROPERTIES_WORKING_DIR |
- PROPERTIES_ARGUMENTS | PROPERTIES_DESCRIPTION |
- PROPERTIES_ICON | PROPERTIES_APP_ID |
- PROPERTIES_DUAL_MODE | PROPERTIES_TOAST_ACTIVATOR_CLSID
- };
- ShortcutProperties();
- ShortcutProperties(const ShortcutProperties& other);
- ~ShortcutProperties();
- void set_target(const FilePath& target_in) {
- target = target_in;
- options |= PROPERTIES_TARGET;
- }
- void set_working_dir(const FilePath& working_dir_in) {
- working_dir = working_dir_in;
- options |= PROPERTIES_WORKING_DIR;
- }
- void set_arguments(const std::wstring& arguments_in) {
-
- DCHECK(arguments_in.size() < MAX_PATH);
- arguments = arguments_in;
- options |= PROPERTIES_ARGUMENTS;
- }
- void set_description(const std::wstring& description_in) {
-
- DCHECK(description_in.size() < MAX_PATH);
- description = description_in;
- options |= PROPERTIES_DESCRIPTION;
- }
- void set_icon(const FilePath& icon_in, int icon_index_in) {
- icon = icon_in;
- icon_index = icon_index_in;
- options |= PROPERTIES_ICON;
- }
- void set_app_id(const std::wstring& app_id_in) {
- app_id = app_id_in;
- options |= PROPERTIES_APP_ID;
- }
- void set_dual_mode(bool dual_mode_in) {
- dual_mode = dual_mode_in;
- options |= PROPERTIES_DUAL_MODE;
- }
- void set_toast_activator_clsid(const CLSID& toast_activator_clsid_in) {
- toast_activator_clsid = toast_activator_clsid_in;
- options |= PROPERTIES_TOAST_ACTIVATOR_CLSID;
- }
-
-
- FilePath target;
-
- FilePath working_dir;
-
-
- std::wstring arguments;
-
-
- std::wstring description;
-
-
- FilePath icon;
- int icon_index = -1;
-
- std::wstring app_id;
-
- bool dual_mode = false;
-
-
-
- CLSID toast_activator_clsid;
-
-
- uint32_t options = 0U;
- };
- BASE_EXPORT bool CreateOrUpdateShortcutLink(
- const FilePath& shortcut_path,
- const ShortcutProperties& properties,
- ShortcutOperation operation);
- BASE_EXPORT bool ResolveShortcutProperties(const FilePath& shortcut_path,
- uint32_t options,
- ShortcutProperties* properties);
- BASE_EXPORT bool ResolveShortcut(const FilePath& shortcut_path,
- FilePath* target_path,
- std::wstring* args);
- BASE_EXPORT bool CanPinShortcutToTaskbar();
- BASE_EXPORT bool PinShortcutToTaskbar(const FilePath& shortcut);
- BASE_EXPORT bool UnpinShortcutFromTaskbar(const FilePath& shortcut);
- }
- }
- #endif
|