OLD | NEW |
| (Empty) |
1 // Copyright 2003-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 // | |
16 // Shell functions | |
17 // | |
18 // create shortcut links | |
19 // remove shortcut links | |
20 | |
21 #ifndef OMAHA_BASE_SHELL_H_ | |
22 #define OMAHA_BASE_SHELL_H_ | |
23 | |
24 #include <windows.h> | |
25 #include <shlobj.h> // for the CSIDL definitions | |
26 #include <atlstr.h> | |
27 #include <map> | |
28 | |
29 #include "base/basictypes.h" | |
30 | |
31 namespace omaha { | |
32 | |
33 // TODO(omaha): Use BrowserType instead. | |
34 enum UseBrowser { | |
35 USE_DEFAULT_BROWSER = 0, | |
36 USE_INTERNET_EXPLORER = 1, | |
37 USE_FIREFOX = 2 | |
38 }; | |
39 | |
40 class Shell { | |
41 public: | |
42 | |
43 // create and store a shortcut link | |
44 // note that icon can be NULL if no icon is required | |
45 // note that we always pick the 0th icon for now, this can be changed later | |
46 // [relevant with EXE and compound icons] | |
47 static HRESULT CreateLink(const TCHAR *source, | |
48 const TCHAR *destination, | |
49 const TCHAR *working_dir, | |
50 const TCHAR *arguments, | |
51 const TCHAR *description, | |
52 WORD hotkey_virtual_key_code, | |
53 WORD hotkey_modifiers, | |
54 const TCHAR *icon); | |
55 // For information on hotkey modifiers see MSDN IShellLink::GetHotKey method. | |
56 | |
57 // Delete a shortcut link | |
58 static HRESULT RemoveLink(const TCHAR *link); | |
59 | |
60 // Open a URL in a new browser window | |
61 static HRESULT OpenLinkInNewWindow(const TCHAR* url, UseBrowser use_browser); | |
62 | |
63 // Execute a file | |
64 static HRESULT Shell::Execute(const TCHAR* file); | |
65 | |
66 // Get the location of a special folder. The special folders are identified | |
67 // by a unique integer - see the platform SDK files shfolder.h and | |
68 // shlobj.h. (These names will be the localized versions for the | |
69 // system that is running.) | |
70 static HRESULT GetSpecialFolder(DWORD csidl, | |
71 bool create_if_missing, | |
72 CString* folder_path); | |
73 | |
74 // Get a mapping from special folder "env var" names to special folder | |
75 // pathnames. | |
76 // Provides mappings for: APPDATA, DESKTOP, LOCALAPPDATA, MYMUSIC, MYPICTURES, | |
77 // PROGRAMFILES, PROGRAMFILESCOMMON, PROGRAMS, STARTMENU, STARTUP, SYSTEM, | |
78 // WINDOWS. | |
79 static HRESULT GetSpecialFolderKeywordsMapping( | |
80 std::map<CString, CString>* special_folders_map); | |
81 | |
82 // Recursively delete a directory including its files. | |
83 static HRESULT DeleteDirectory(const TCHAR* dir); | |
84 | |
85 // Reads the application executable path from | |
86 // HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths. | |
87 static HRESULT GetApplicationExecutablePath(const CString& exe, | |
88 CString* path); | |
89 | |
90 private: | |
91 | |
92 static HRESULT BasicGetSpecialFolder(DWORD csidl, CString* folder_path); | |
93 | |
94 DISALLOW_EVIL_CONSTRUCTORS(Shell); | |
95 }; | |
96 | |
97 } // namespace omaha | |
98 | |
99 #endif // OMAHA_BASE_SHELL_H_ | |
OLD | NEW |