Create the AHCI branch for Aman's work
[reactos.git] / base / shell / explorer / startmnucust.cpp
1 /*
2 * ReactOS Explorer
3 *
4 * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
5 * 2015 Robert Naumann <gonzomdx@gmail.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "precomp.h"
23
24 VOID OnAddStartmenuItems(HWND hDlg)
25 {
26 WCHAR szPath[MAX_PATH];
27
28 if(SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_STARTMENU, NULL, 0, szPath)))
29 {
30 WCHAR szCommand[MAX_PATH] = L"appwiz.cpl,NewLinkHere ";
31 if(SUCCEEDED(StringCchCatW(szCommand, MAX_PATH, szPath)))
32 ShellExecuteW(hDlg, L"open", L"rundll32.exe", szCommand, NULL, SW_SHOWNORMAL);
33 }
34 }
35
36 VOID OnAdvancedStartMenuItems()
37 {
38 WCHAR szPath[MAX_PATH];
39
40 if(SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_STARTMENU, NULL, 0, szPath)))
41 {
42 ShellExecuteW(NULL, L"explore", szPath, NULL, NULL, SW_SHOWNORMAL);
43 }
44 }
45
46 VOID OnClearRecentItems()
47 {
48 WCHAR szPath[MAX_PATH], szFile[MAX_PATH];
49 WIN32_FIND_DATA info;
50 HANDLE hPath;
51
52 if(SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_RECENT, NULL, 0, szPath)))
53 {
54 StringCchPrintf(szFile,MAX_PATH, L"%s\\*.*", szPath);
55 hPath = FindFirstFileW(szFile, &info);
56 do
57 {
58 StringCchPrintf(szFile,MAX_PATH, L"%s\\%s", szPath, info.cFileName);
59 DeleteFileW(szFile);
60
61 }while(FindNextFileW(hPath, &info));
62 FindClose(hPath);
63 /* FIXME: Disable the button*/
64 }
65 }
66
67 INT_PTR CALLBACK CustomizeClassicProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
68 {
69 switch(Message)
70 {
71 case WM_INITDIALOG:
72 /* FIXME: Properly intialize the dialog (check whether 'clear' button must be disabled, for example) */
73 return TRUE;
74 case WM_COMMAND:
75 switch(LOWORD(wParam))
76 {
77 case IDC_CLASSICSTART_ADD:
78 OnAddStartmenuItems(hwnd);
79 break;
80 case IDC_CLASSICSTART_ADVANCED:
81 OnAdvancedStartMenuItems();
82 break;
83 case IDC_CLASSICSTART_CLEAR:
84 OnClearRecentItems();
85 break;
86 case IDOK:
87 EndDialog(hwnd, IDOK);
88 break;
89 case IDCANCEL:
90 EndDialog(hwnd, IDCANCEL);
91 break;
92 }
93 break;
94 default:
95 return FALSE;
96 }
97 return TRUE;
98 }
99
100 VOID ShowCustomizeClassic(HINSTANCE hInst, HWND hExplorer)
101 {
102 DialogBox(hInst, MAKEINTRESOURCE(IDD_CLASSICSTART_CUSTOMIZE), hExplorer, CustomizeClassicProc);
103 }