ReactOS 0.4.16-dev-1163-gec5b142
dialogs.cpp
Go to the documentation of this file.
1/*
2 * common shell dialogs
3 *
4 * Copyright 2000 Juergen Schmied
5 * Copyright 2018 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 * Copyright 2021 Arnav Bhatt <arnavbhatt288@gmail.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23#include "precomp.h"
24
25typedef struct
26{
35
36typedef struct
37{
39 BOOL bIsButtonHot[2];
41 HBRUSH hBrush;
45
47
50static void FillList(HWND, LPWSTR, UINT, BOOL);
51
52
53/*************************************************************************
54 * PickIconDlg [SHELL32.62]
55 *
56 */
57
58typedef struct
59{
67
69 LPCWSTR lpszType,
70 LPWSTR lpszName,
72{
74 HWND hDlgCtrl = pIconContext->hDlgCtrl;
75
76 if (IS_INTRESOURCE(lpszName))
77 lParam = LOWORD(lpszName);
78 else
79 lParam = -1;
80
81 SendMessageW(hDlgCtrl, LB_ADDSTRING, 0, lParam);
82
83 return TRUE;
84}
85
86static void
88{
89 int count;
90 int index;
91
92 count = SendMessageW(hDlgCtrl, LB_GETCOUNT, 0, 0);
93 if (count == LB_ERR)
94 return;
95
96 for(index = 0; index < count; index++)
97 {
98 DestroyIcon(pIconContext->phIcons[index]);
99 pIconContext->phIcons[index] = NULL;
100 }
101}
102
103static BOOL
104DoLoadIcons(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext, LPCWSTR pszFile)
105{
106 WCHAR szExpandedPath[MAX_PATH];
107
108 // Destroy previous icons
109 DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
110 SendMessageW(pIconContext->hDlgCtrl, LB_RESETCONTENT, 0, 0);
111 delete[] pIconContext->phIcons;
112
113 // Store the path
114 StringCchCopyW(pIconContext->szPath, _countof(pIconContext->szPath), pszFile);
115 ExpandEnvironmentStringsW(pszFile, szExpandedPath, _countof(szExpandedPath));
116
117 // Load the module if possible
119 if (pIconContext->hLibrary)
120 FreeLibrary(pIconContext->hLibrary);
121 pIconContext->hLibrary = hLibrary;
122
123 if (pIconContext->hLibrary)
124 {
125 // Load the icons from the module
126 pIconContext->nIcons = ExtractIconExW(szExpandedPath, -1, NULL, NULL, 0);
127 pIconContext->phIcons = new HICON[pIconContext->nIcons];
128
129 if (ExtractIconExW(szExpandedPath, 0, pIconContext->phIcons, NULL, pIconContext->nIcons))
130 {
132 }
133 else
134 {
135 pIconContext->nIcons = 0;
136 }
137 }
138 else
139 {
140 // .ico file
141 pIconContext->nIcons = 1;
142 pIconContext->phIcons = new HICON[1];
143
144 if (ExtractIconExW(szExpandedPath, 0, pIconContext->phIcons, NULL, pIconContext->nIcons))
145 {
146 SendMessageW(pIconContext->hDlgCtrl, LB_ADDSTRING, 0, 0);
147 }
148 else
149 {
150 pIconContext->nIcons = 0;
151 }
152 }
153
154 SetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath);
155 SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
156
157 if (pIconContext->nIcons == 0)
158 {
159 delete[] pIconContext->phIcons;
160 pIconContext->phIcons = NULL;
161 }
162
163 return (pIconContext->nIcons > 0);
164}
165
166static void NoIconsInFile(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext)
167{
168 // Show an error message
169 CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
170 strText.Format(IDS_NO_ICONS, pIconContext->szPath);
171 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONWARNING);
172
173 // Load the default icons
174 DoLoadIcons(hwndDlg, pIconContext, g_pszShell32);
175}
176
177// Icon size
178#define CX_ICON GetSystemMetrics(SM_CXICON)
179#define CY_ICON GetSystemMetrics(SM_CYICON)
180
181// Item size
182#define CX_ITEM (CX_ICON + 4)
183#define CY_ITEM (CY_ICON + 12)
184
186 HWND hwndDlg,
187 UINT uMsg,
190{
192 LPDRAWITEMSTRUCT lpdis;
193 HICON hIcon;
194 INT index, count;
195 WCHAR szText[MAX_PATH], szFilter[100];
198
199 switch(uMsg)
200 {
201 case WM_INITDIALOG:
202 {
203 pIconContext = (PPICK_ICON_CONTEXT)lParam;
204 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pIconContext);
205 pIconContext->hDlgCtrl = GetDlgItem(hwndDlg, IDC_PICKICON_LIST);
206
207 SendMessageW(pIconContext->hDlgCtrl, LB_SETCOLUMNWIDTH, CX_ITEM, 0);
208
209 // Load the icons
210 if (!DoLoadIcons(hwndDlg, pIconContext, pIconContext->szPath))
211 NoIconsInFile(hwndDlg, pIconContext);
212
213 // Set the selection
214 count = SendMessageW(pIconContext->hDlgCtrl, LB_GETCOUNT, 0, 0);
215 if (count != LB_ERR)
216 {
217 if (pIconContext->Index < 0)
218 {
219 // A negative value will be interpreted as a negated resource ID.
220 LPARAM lParam = -pIconContext->Index;
221 pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_FINDSTRINGEXACT, -1, lParam);
222 }
223
224 if (pIconContext->Index < 0 || count <= pIconContext->Index)
225 pIconContext->Index = 0;
226
227 SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, pIconContext->Index, 0);
228 SendMessageW(pIconContext->hDlgCtrl, LB_SETTOPINDEX, pIconContext->Index, 0);
229 }
230
232 return TRUE;
233 }
234
235 case WM_DESTROY:
236 {
237 DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
238 delete[] pIconContext->phIcons;
239
240 if (pIconContext->hLibrary)
241 FreeLibrary(pIconContext->hLibrary);
242 break;
243 }
244
245 case WM_COMMAND:
246 switch(LOWORD(wParam))
247 {
248 case IDOK:
249 {
250 /* Check whether the path edit control has been modified; if so load the icons instead of validating */
251 GetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, szText, _countof(szText));
252 if (lstrcmpiW(szText, pIconContext->szPath))
253 {
254 if (!DoLoadIcons(hwndDlg, pIconContext, szText))
255 NoIconsInFile(hwndDlg, pIconContext);
256 break;
257 }
258
259 /* The path edit control has not been modified, return the selection */
260 pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
261 GetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath, _countof(pIconContext->szPath));
262 EndDialog(hwndDlg, 1);
263 break;
264 }
265
266 case IDCANCEL:
267 EndDialog(hwndDlg, 0);
268 break;
269
271 switch (HIWORD(wParam))
272 {
273 case LBN_SELCHANGE:
275 break;
276
277 case LBN_DBLCLK:
278 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);
279 break;
280 }
281 break;
282
283 case IDC_BUTTON_PATH:
284 {
285 // Choose the module path
286 CStringW strTitle;
287 szText[0] = 0;
288 szFilter[0] = 0;
289 ZeroMemory(&ofn, sizeof(ofn));
290 ofn.lStructSize = sizeof(ofn);
291 ofn.hwndOwner = hwndDlg;
292 ofn.lpstrFile = szText;
293 ofn.nMaxFile = _countof(szText);
294 strTitle.LoadString(IDS_PICK_ICON_TITLE);
295 ofn.lpstrTitle = strTitle;
298 if (!GetOpenFileNameW(&ofn))
299 break;
300
301 // Load the icons
302 if (!DoLoadIcons(hwndDlg, pIconContext, szText))
303 NoIconsInFile(hwndDlg, pIconContext);
304 break;
305 }
306
307 default:
308 break;
309 }
310 break;
311
312 case WM_MEASUREITEM:
314 lpmis->itemHeight = CY_ITEM;
315 return TRUE;
316
317 case WM_DRAWITEM:
318 {
319 lpdis = (LPDRAWITEMSTRUCT)lParam;
320 if (lpdis->itemID == (UINT)-1)
321 break;
322 switch (lpdis->itemAction) // FIXME: MSDN says that more than one of these can be set
323 {
324 // FIXME: ODA_FOCUS
325 case ODA_SELECT:
326 case ODA_DRAWENTIRE:
327 {
328 index = SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
329 hIcon = pIconContext->phIcons[lpdis->itemID];
330
331 if (lpdis->itemID == (UINT)index)
332 FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
333 else
334 FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
335
336 // Centering
337 INT x = lpdis->rcItem.left + (CX_ITEM - CX_ICON) / 2;
338 INT y = lpdis->rcItem.top + (CY_ITEM - CY_ICON) / 2;
339
340 DrawIconEx(lpdis->hDC, x, y, hIcon, 0, 0, 0, NULL, DI_NORMAL);
341 break;
342 }
343 }
344 return TRUE;
345 }
346 }
347
348 return FALSE;
349}
350
352 HWND hWndOwner,
353 LPWSTR lpstrFile,
354 UINT nMaxFile,
355 INT* lpdwIconIndex)
356{
357 CCoInit ComInit; // For SHAutoComplete (CORE-20030)
358 int res;
359 WCHAR szExpandedPath[MAX_PATH];
360
361 // Initialize the dialog
362 PICK_ICON_CONTEXT IconContext = { NULL };
363 IconContext.Index = *lpdwIconIndex;
364 StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), lpstrFile);
365 ExpandEnvironmentStringsW(lpstrFile, szExpandedPath, _countof(szExpandedPath));
366
367 if (!szExpandedPath[0] ||
369 {
370 if (szExpandedPath[0])
371 {
372 // No such file
373 CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
374 strText.Format(IDS_FILE_NOT_FOUND, lpstrFile);
375 MessageBoxW(hWndOwner, strText, strTitle, MB_ICONWARNING);
376 }
377
378 // Set the default value
379 StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), g_pszShell32);
380 }
381
382 // Show the dialog
384 if (res)
385 {
386 // Store the selected icon
387 StringCchCopyW(lpstrFile, nMaxFile, IconContext.szPath);
388 *lpdwIconIndex = IconContext.Index;
389 }
390
391 return res;
392}
393
394/*************************************************************************
395 * RunFileDlg [internal]
396 *
397 * The Unicode function that is available as ordinal 61 on Windows NT/2000/XP/...
398 */
400 HWND hWndOwner,
401 HICON hIcon,
402 LPCWSTR lpstrDirectory,
403 LPCWSTR lpstrTitle,
404 LPCWSTR lpstrDescription,
405 UINT uFlags)
406{
407 TRACE("\n");
408
409 RUNFILEDLGPARAMS rfdp;
410 rfdp.hwndOwner = hWndOwner;
411 rfdp.hIcon = hIcon;
412 rfdp.lpstrDirectory = lpstrDirectory;
413 rfdp.lpstrTitle = lpstrTitle;
414 rfdp.lpstrDescription = lpstrDescription;
415 rfdp.uFlags = uFlags;
416
418}
419
420
421/* find the directory that contains the file being run */
423{
424 const WCHAR *src;
425 WCHAR *dest, *result, *result_end=NULL;
426
427 result = (WCHAR *)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(strlenW(cmdline)+5));
428
429 if (NULL == result)
430 {
431 TRACE("HeapAlloc couldn't allocate %d bytes\n", sizeof(WCHAR)*(strlenW(cmdline)+5));
432 return NULL;
433 }
434
435 src = cmdline;
436 dest = result;
437
438 if (*src == '"')
439 {
440 src++;
441 while (*src && *src != '"')
442 {
443 if (*src == '\\')
444 result_end = dest;
445 *dest++ = *src++;
446 }
447 }
448 else {
449 while (*src)
450 {
451 if (isspaceW(*src))
452 {
453 *dest = 0;
455 break;
456 strcatW(dest, L".exe");
458 break;
459 }
460 else if (*src == '\\')
461 result_end = dest;
462 *dest++ = *src++;
463 }
464 }
465
466 if (result_end)
467 {
468 *result_end = 0;
469 return result;
470 }
471 else
472 {
474 return NULL;
475 }
476}
477
479{
480 BOOL Enable = FALSE;
481 INT Length, n;
484 if (Length > 0)
485 {
486 PWCHAR psz = (PWCHAR)HeapAlloc(GetProcessHeap(), 0, (Length + 1) * sizeof(WCHAR));
487 if (psz)
488 {
489 GetWindowTextW(Edit, psz, Length + 1);
490 for (n = 0; n < Length && !Enable; ++n)
491 Enable = psz[n] != ' ';
492 HeapFree(GetProcessHeap(), 0, psz);
493 }
494 else
495 Enable = TRUE;
496 }
498}
499
500/* Dialog procedure for RunFileDlg */
502{
504 HWND hwndCombo, hwndEdit;
505 COMBOBOXINFO ComboInfo;
506
507 switch (message)
508 {
509 case WM_INITDIALOG:
510 prfdp = (RUNFILEDLGPARAMS *)lParam;
512
513 if (prfdp->lpstrTitle)
514 SetWindowTextW(hwnd, prfdp->lpstrTitle);
515 if (prfdp->lpstrDescription)
516 SetWindowTextW(GetDlgItem(hwnd, IDC_RUNDLG_DESCRIPTION), prfdp->lpstrDescription);
517 if (prfdp->uFlags & RFF_NOBROWSE)
518 {
520 ShowWindow(browse, SW_HIDE);
521 EnableWindow(browse, FALSE);
522 }
523 if (prfdp->uFlags & RFF_NOLABEL)
525 if (prfdp->uFlags & RFF_NOSEPARATEMEM)
526 {
527 FIXME("RFF_NOSEPARATEMEM not supported\n");
528 }
529
530 /* Use the default Shell Run icon if no one is specified */
531 if (prfdp->hIcon == NULL)
533 /*
534 * NOTE: Starting Windows Vista, the "Run File" dialog gets a
535 * title icon that remains the same as the default one, even if
536 * the user specifies a custom icon.
537 * Since we currently imitate Windows 2003, therefore do not show
538 * any title icon.
539 */
540 // SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM)prfdp->hIcon);
541 // SendMessageW(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)prfdp->hIcon);
543
544 hwndCombo = GetDlgItem(hwnd, IDC_RUNDLG_EDITPATH);
545 FillList(hwndCombo, NULL, 0, (prfdp->uFlags & RFF_NODEFAULT) == 0);
547
548 ComboInfo.cbSize = sizeof(ComboInfo);
549 GetComboBoxInfo(hwndCombo, &ComboInfo);
550 hwndEdit = ComboInfo.hwndItem;
552
553 // SHAutoComplete needs co init
555
557
558 SetFocus(hwndCombo);
559 return TRUE;
560
561 case WM_DESTROY:
562 if (prfdp->bCoInited)
564 break;
565
566 case WM_COMMAND:
567 switch (LOWORD(wParam))
568 {
569 case IDOK:
570 {
571 LRESULT lRet;
573 INT ic;
574 WCHAR *psz, *pszExpanded, *parent = NULL;
575 DWORD cchExpand;
576 SHELLEXECUTEINFOW sei = { sizeof(sei) };
577 NMRUNFILEDLGW nmrfd;
578
579 ic = GetWindowTextLengthW(htxt);
580 if (ic == 0)
581 {
583 return TRUE;
584 }
585
586 /*
587 * Allocate a new MRU entry, we need to add two characters
588 * for the terminating "\\1" part, then the NULL character.
589 */
590 psz = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (ic + 2 + 1)*sizeof(WCHAR));
591 if (!psz)
592 {
594 return TRUE;
595 }
596
597 GetWindowTextW(htxt, psz, ic + 1);
598 sei.hwnd = hwnd;
599 sei.nShow = SW_SHOWNORMAL;
600 sei.lpFile = psz;
601 StrTrimW(psz, L" \t");
602
603 if (wcschr(psz, L'%') != NULL)
604 {
605 cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0);
606 pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR));
607 if (!pszExpanded)
608 {
609 HeapFree(GetProcessHeap(), 0, psz);
611 return TRUE;
612 }
613 ExpandEnvironmentStringsW(psz, pszExpanded, cchExpand);
614 StrTrimW(pszExpanded, L" \t");
615 }
616 else
617 {
618 pszExpanded = psz;
619 }
620
621 /*
622 * The precedence is the following: first the user-given
623 * current directory is used; if there is none, a current
624 * directory is computed if the RFF_CALCDIRECTORY is set,
625 * otherwise no current directory is defined.
626 */
627 LPCWSTR pszStartDir;
628 if (prfdp->lpstrDirectory)
629 {
630 sei.lpDirectory = prfdp->lpstrDirectory;
631 pszStartDir = prfdp->lpstrDirectory;
632 }
633 else if (prfdp->uFlags & RFF_CALCDIRECTORY)
634 {
636 pszStartDir = parent = RunDlg_GetParentDir(pszExpanded);
637 }
638 else
639 {
640 sei.lpDirectory = NULL;
641 pszStartDir = NULL;
642 }
643
644 /* Hide the dialog for now on, we will show it up in case of retry */
646
647 /*
648 * As shown by manual tests on Windows, modifying the contents
649 * of the notification structure will not modify what the
650 * Run-Dialog will use for the nShow parameter. However the
651 * lpFile and lpDirectory pointers are set to the buffers used
652 * by the Run-Dialog, as a consequence they can be modified by
653 * the notification receiver, as long as it respects the lengths
654 * of the buffers (to avoid buffer overflows).
655 */
656 nmrfd.hdr.code = RFN_VALIDATE;
657 nmrfd.hdr.hwndFrom = hwnd;
658 nmrfd.hdr.idFrom = 0;
659 nmrfd.lpFile = pszExpanded;
660 nmrfd.lpDirectory = pszStartDir;
661 nmrfd.nShow = SW_SHOWNORMAL;
662
663 lRet = SendMessageW(prfdp->hwndOwner, WM_NOTIFY, 0, (LPARAM)&nmrfd.hdr);
664
665 switch (lRet)
666 {
667 case RF_CANCEL:
669 break;
670
671 case RF_OK:
672 /* We use SECL_NO_UI because we don't want to see
673 * errors here, but we will try again below and
674 * there we will output our errors. */
675 if (SUCCEEDED(ShellExecCmdLine(hwnd, pszExpanded, pszStartDir, SW_SHOWNORMAL, NULL,
677 {
678 /* Call GetWindowText again in case the contents of the edit box have changed. */
679 GetWindowTextW(htxt, psz, ic + 1);
680 FillList(htxt, psz, ic + 2 + 1, FALSE);
682 break;
683 }
684 else if (ShellExecuteExW(&sei))
685 {
686 /* Call GetWindowText again in case the contents of the edit box have changed. */
687 GetWindowTextW(htxt, psz, ic + 1);
688 FillList(htxt, psz, ic + 2 + 1, FALSE);
690 break;
691 }
692
693 /* Fall-back */
694 case RF_RETRY:
695 default:
696 SendMessageW(htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
697 /* Show back the dialog */
699 break;
700 }
701
703 HeapFree(GetProcessHeap(), 0, psz);
704 if (psz != pszExpanded)
705 HeapFree(GetProcessHeap(), 0, pszExpanded);
706 return TRUE;
707 }
708
709 case IDCANCEL:
711 return TRUE;
712
714 {
715 HMODULE hComdlg = NULL;
716 LPFNOFN ofnProc = NULL;
717 WCHAR szFName[1024] = {0};
718 WCHAR filter[MAX_PATH], szCaption[MAX_PATH];
720
723
724 ZeroMemory(&ofn, sizeof(ofn));
725 ofn.lStructSize = sizeof(ofn);
728 ofn.lpstrFile = szFName;
729 ofn.nMaxFile = _countof(szFName) - 1;
730 ofn.lpstrTitle = szCaption;
732 ofn.lpstrInitialDir = prfdp->lpstrDirectory;
733
734 if (NULL == (hComdlg = LoadLibraryExW(L"comdlg32", NULL, 0)) ||
735 NULL == (ofnProc = (LPFNOFN)GetProcAddress(hComdlg, "GetOpenFileNameW")))
736 {
737 ERR("Couldn't get GetOpenFileName function entry (lib=%p, proc=%p)\n", hComdlg, ofnProc);
739 return TRUE;
740 }
741
742 if (ofnProc(&ofn))
743 {
749 }
750
751 FreeLibrary(hComdlg);
752
753 return TRUE;
754 }
756 {
759
760 // Delay handling dropdown changes until the edit box has been updated.
763 return TRUE;
764 }
765 }
766 return TRUE;
767 }
768 return FALSE;
769}
770
771/*
772 * This function grabs the MRU list from the registry and fills the combo-list
773 * for the "Run" dialog above. fShowDefault is ignored if pszLatest != NULL.
774 */
775// FIXME: Part of this code should be part of some MRUList API,
776// that is scattered amongst shell32, comctl32 (?!) and comdlg32.
777static void FillList(HWND hCb, LPWSTR pszLatest, UINT cchStr, BOOL fShowDefault)
778{
779 HKEY hkey;
780 WCHAR *pszList = NULL, *pszCmd = NULL, *pszTmp = NULL, cMatch = 0, cMax = 0x60;
781 WCHAR szIndex[2] = L"-";
782 UINT cchLatest;
783 DWORD dwType, icList = 0, icCmd = 0;
784 LRESULT lRet;
785 UINT Nix;
786
787 /*
788 * Retrieve the string length of pszLatest and check whether its buffer size
789 * (cchStr in number of characters) is large enough to add the terminating "\\1"
790 * (and the NULL character).
791 */
792 if (pszLatest)
793 {
794 cchLatest = wcslen(pszLatest);
795 if (cchStr < cchLatest + 2 + 1)
796 {
797 TRACE("pszLatest buffer is not large enough (%d) to hold the MRU terminator.\n", cchStr);
798 return;
799 }
800 }
801 else
802 {
803 cchStr = 0;
804 }
805
806 SendMessageW(hCb, CB_RESETCONTENT, 0, 0);
807
809 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU",
811 if (lRet != ERROR_SUCCESS)
812 {
813 TRACE("Unable to open or create the RunMRU key, error %d\n", GetLastError());
814 return;
815 }
816
817 lRet = RegQueryValueExW(hkey, L"MRUList", NULL, &dwType, NULL, &icList);
818 if (lRet == ERROR_SUCCESS && dwType == REG_SZ && icList > sizeof(WCHAR))
819 {
820 pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icList);
821 if (!pszList)
822 {
823 TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
824 goto Continue;
825 }
826 pszList[0] = L'\0';
827
828 lRet = RegQueryValueExW(hkey, L"MRUList", NULL, NULL, (LPBYTE)pszList, &icList);
829 if (lRet != ERROR_SUCCESS)
830 {
831 TRACE("Unable to grab MRUList, error %d\n", GetLastError());
832 pszList[0] = L'\0';
833 }
834 }
835 else
836 {
837Continue:
838 icList = sizeof(WCHAR);
839 pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icList);
840 if (!pszList)
841 {
842 TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
843 RegCloseKey(hkey);
844 return;
845 }
846 pszList[0] = L'\0';
847 }
848
849 /* Convert the number of bytes from MRUList into number of characters (== number of indices) */
850 icList /= sizeof(WCHAR);
851
852 for (Nix = 0; Nix < icList - 1; Nix++)
853 {
854 if (pszList[Nix] > cMax)
855 cMax = pszList[Nix];
856
857 szIndex[0] = pszList[Nix];
858
859 lRet = RegQueryValueExW(hkey, szIndex, NULL, &dwType, NULL, &icCmd);
860 if (lRet != ERROR_SUCCESS || dwType != REG_SZ)
861 {
862 TRACE("Unable to grab size of index, error %d\n", GetLastError());
863 continue;
864 }
865
866 if (pszCmd)
867 {
868 pszTmp = (WCHAR*)HeapReAlloc(GetProcessHeap(), 0, pszCmd, icCmd);
869 if (!pszTmp)
870 {
871 TRACE("HeapReAlloc failed to reallocate %d bytes\n", icCmd);
872 continue;
873 }
874 pszCmd = pszTmp;
875 }
876 else
877 {
878 pszCmd = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icCmd);
879 if (!pszCmd)
880 {
881 TRACE("HeapAlloc failed to allocate %d bytes\n", icCmd);
882 continue;
883 }
884 }
885
886 lRet = RegQueryValueExW(hkey, szIndex, NULL, NULL, (LPBYTE)pszCmd, &icCmd);
887 if (lRet != ERROR_SUCCESS)
888 {
889 TRACE("Unable to grab index, error %d\n", GetLastError());
890 continue;
891 }
892
893 /*
894 * Generally the command string will end up with "\\1".
895 * Find the last backslash in the string and NULL-terminate.
896 * Windows does not seem to check for what comes next, so that
897 * a command of the form:
898 * c:\\my_dir\\myfile.exe
899 * will be cut just after "my_dir", whereas a command of the form:
900 * c:\\my_dir\\myfile.exe\\1
901 * will be cut just after "myfile.exe".
902 */
903 pszTmp = wcsrchr(pszCmd, L'\\');
904 if (pszTmp)
905 *pszTmp = L'\0';
906
907 /*
908 * In the following we try to add pszLatest to the MRU list.
909 * We suppose that our caller has already correctly allocated
910 * the string with enough space for us to append a "\\1".
911 *
912 * FIXME: TODO! (At the moment we don't append it!)
913 */
914
915 if (pszLatest)
916 {
917 if (_wcsicmp(pszCmd, pszLatest) == 0)
918 {
919 SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszCmd);
920 SetWindowTextW(hCb, pszCmd);
921 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
922
923 cMatch = pszList[Nix];
924 memmove(&pszList[1], pszList, Nix * sizeof(WCHAR));
925 pszList[0] = cMatch;
926 continue;
927 }
928 }
929
930 if (icList - 1 != 26 || icList - 2 != Nix || cMatch || pszLatest == NULL)
931 {
932 SendMessageW(hCb, CB_ADDSTRING, 0, (LPARAM)pszCmd);
933 if (!Nix && fShowDefault)
934 {
935 SetWindowTextW(hCb, pszCmd);
936 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
937 }
938 }
939 else
940 {
941 SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest);
942 SetWindowTextW(hCb, pszLatest);
943 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
944
945 cMatch = pszList[Nix];
946 memmove(&pszList[1], pszList, Nix * sizeof(WCHAR));
947 pszList[0] = cMatch;
948 szIndex[0] = cMatch;
949
950 wcscpy(&pszLatest[cchLatest], L"\\1");
951 RegSetValueExW(hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, (cchLatest + 2 + 1) * sizeof(WCHAR));
952 pszLatest[cchLatest] = L'\0';
953 }
954 }
955
956 if (!cMatch && pszLatest != NULL)
957 {
958 SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest);
959 SetWindowTextW(hCb, pszLatest);
960 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
961
962 cMatch = ++cMax;
963
964 if (pszList)
965 {
966 pszTmp = (WCHAR*)HeapReAlloc(GetProcessHeap(), 0, pszList, (++icList) * sizeof(WCHAR));
967 if (!pszTmp)
968 {
969 TRACE("HeapReAlloc failed to reallocate enough bytes\n");
970 goto Cleanup;
971 }
972 pszList = pszTmp;
973 }
974 else
975 {
976 pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (++icList) * sizeof(WCHAR));
977 if (!pszList)
978 {
979 TRACE("HeapAlloc failed to allocate enough bytes\n");
980 goto Cleanup;
981 }
982 }
983
984 memmove(&pszList[1], pszList, (icList - 1) * sizeof(WCHAR));
985 pszList[0] = cMatch;
986 szIndex[0] = cMatch;
987
988 wcscpy(&pszLatest[cchLatest], L"\\1");
989 RegSetValueExW(hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, (cchLatest + 2 + 1) * sizeof(WCHAR));
990 pszLatest[cchLatest] = L'\0';
991 }
992
993Cleanup:
994 RegSetValueExW(hkey, L"MRUList", 0, REG_SZ, (LPBYTE)pszList, (wcslen(pszList) + 1) * sizeof(WCHAR));
995
996 HeapFree(GetProcessHeap(), 0, pszCmd);
997 HeapFree(GetProcessHeap(), 0, pszList);
998
999 RegCloseKey(hkey);
1000}
1001
1002
1003/*************************************************************************
1004 * ConfirmDialog [internal]
1005 *
1006 * Put up a confirm box, return TRUE if the user confirmed
1007 */
1008static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
1009{
1010 WCHAR Prompt[256];
1011 WCHAR Title[256];
1012
1013 LoadStringW(shell32_hInstance, PromptId, Prompt, _countof(Prompt));
1015 return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO | MB_ICONQUESTION) == IDYES;
1016}
1017
1019
1020BOOL
1022{
1024 static BOOL Initialized = FALSE;
1025 if (!Initialized)
1026 {
1027 HMODULE mod = LoadLibraryW(L"msgina.dll");
1029 Initialized = TRUE;
1030 }
1031
1032 HRESULT hr = E_FAIL;
1033 if (ShellDimScreen)
1034 hr = ShellDimScreen(pUnknown, hWindow);
1035 return SUCCEEDED(hr);
1036}
1037
1038
1039/* Used to get the shutdown privilege */
1040static BOOL
1041EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
1042{
1043 BOOL Success;
1044 HANDLE hToken;
1046
1049 &hToken);
1050 if (!Success) return Success;
1051
1053 lpszPrivilegeName,
1054 &tp.Privileges[0].Luid);
1055 if (!Success) goto Quit;
1056
1057 tp.PrivilegeCount = 1;
1058 tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
1059
1060 Success = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
1061
1062Quit:
1063 CloseHandle(hToken);
1064 return Success;
1065}
1066
1067/*************************************************************************
1068 * RestartDialogEx [SHELL32.730]
1069 */
1070
1071int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
1072{
1073 TRACE("(%p)\n", hWndOwner);
1074
1075 CComPtr<IUnknown> fadeHandler;
1076 HWND parent;
1077
1078 if (!CallShellDimScreen(&fadeHandler, &parent))
1079 parent = hWndOwner;
1080
1081 /* FIXME: use lpwstrReason */
1083 {
1084 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1085 ExitWindowsEx(EWX_REBOOT, uReason);
1086 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1087 }
1088
1089 return 0;
1090}
1091
1092/* Functions and macros used for fancy log off dialog box */
1093#define IS_PRODUCT_VERSION_WORKSTATION 0x300
1094#define FRIENDLY_LOGOFF_IS_NOT_ENFORCED 0x0
1095
1096#define FONT_POINT_SIZE 13
1097
1098#define DARK_GREY_COLOR RGB(244, 244, 244)
1099#define LIGHT_GREY_COLOR RGB(38, 38, 38)
1100
1101/* Bitmap's size for buttons */
1102#define CX_BITMAP 33
1103#define CY_BITMAP 33
1104
1105#define NUMBER_OF_BUTTONS 2
1106
1107/* After determining the button as well as its state paint the image strip bitmap using these predefined positions */
1108#define BUTTON_SWITCH_USER 0
1109#define BUTTON_SWITCH_USER_PRESSED (CY_BITMAP + BUTTON_SWITCH_USER)
1110#define BUTTON_SWITCH_USER_FOCUSED (CY_BITMAP + BUTTON_SWITCH_USER_PRESSED)
1111#define BUTTON_LOG_OFF (CY_BITMAP + BUTTON_SWITCH_USER_FOCUSED)
1112#define BUTTON_LOG_OFF_PRESSED (CY_BITMAP + BUTTON_LOG_OFF)
1113#define BUTTON_LOG_OFF_FOCUSED (CY_BITMAP + BUTTON_LOG_OFF_PRESSED)
1114#define BUTTON_SWITCH_USER_DISABLED (CY_BITMAP + BUTTON_LOG_OFF_FOCUSED) // Temporary
1115
1116/* For bIsButtonHot */
1117#define LOG_OFF_BUTTON_HOT 0
1118#define SWITCH_USER_BUTTON_HOT 1
1119
1121{
1122 BOOL bRet = FALSE;
1123 HDC hdcMem = NULL;
1124 HBITMAP hbmOld = NULL;
1125 int y = 0;
1126 RECT rect;
1127
1128 hdcMem = CreateCompatibleDC(pdis->hDC);
1129 hbmOld = (HBITMAP)SelectObject(hdcMem, pContext->hImageStrip);
1130 rect = pdis->rcItem;
1131
1132 /* Check the button ID for revelant bitmap to be used */
1133 switch (pdis->CtlID)
1134 {
1135 case IDC_LOG_OFF_BUTTON:
1136 {
1137 switch (pdis->itemAction)
1138 {
1139 case ODA_DRAWENTIRE:
1140 case ODA_FOCUS:
1141 case ODA_SELECT:
1142 {
1143 y = BUTTON_LOG_OFF;
1144 if (pdis->itemState & ODS_SELECTED)
1145 {
1147 }
1148 else if (pContext->bIsButtonHot[LOG_OFF_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
1149 {
1151 }
1152 break;
1153 }
1154 }
1155 break;
1156 }
1157
1159 {
1160 switch (pdis->itemAction)
1161 {
1162 case ODA_DRAWENTIRE:
1163 case ODA_FOCUS:
1164 case ODA_SELECT:
1165 {
1167 if (pdis->itemState & ODS_SELECTED)
1168 {
1170 }
1171 else if (pContext->bIsButtonHot[SWITCH_USER_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
1172 {
1174 }
1175
1176 /*
1177 * Since switch user functionality isn't implemented yet therefore the button has been disabled
1178 * temporarily hence show the disabled state
1179 */
1180 else if (pdis->itemState & ODS_DISABLED)
1181 {
1183 }
1184 break;
1185 }
1186 }
1187 break;
1188 }
1189 }
1190
1191 /* Draw it on the required button */
1192 bRet = BitBlt(pdis->hDC,
1193 (rect.right - rect.left - CX_BITMAP) / 2,
1194 (rect.bottom - rect.top - CY_BITMAP) / 2,
1196
1197 SelectObject(hdcMem, hbmOld);
1199
1200 return bRet;
1201}
1202
1204{
1205 PLOGOFF_DLG_CONTEXT pContext;
1207
1208 int buttonID = GetDlgCtrlID(hButton);
1209
1210 switch (uMsg)
1211 {
1212 case WM_MOUSEMOVE:
1213 {
1214 HWND hwndTarget = NULL;
1216
1217 if (GetCapture() != hButton)
1218 {
1219 SetCapture(hButton);
1220
1221 switch (buttonID)
1222 {
1223 case IDC_LOG_OFF_BUTTON:
1224 {
1226 break;
1227 }
1229 {
1231 break;
1232 }
1233 }
1235 }
1236
1237 ClientToScreen(hButton, &pt);
1238 hwndTarget = WindowFromPoint(pt);
1239
1240 if (hwndTarget != hButton)
1241 {
1243
1244 switch (buttonID)
1245 {
1246 case IDC_LOG_OFF_BUTTON:
1247 {
1249 break;
1250 }
1252 {
1254 break;
1255 }
1256 }
1257 }
1258 InvalidateRect(hButton, NULL, FALSE);
1259 break;
1260 }
1261
1262 /* Whenever one of the buttons gets the keyboard focus, set it as default button */
1263 case WM_SETFOCUS:
1264 {
1265 SendMessageW(GetParent(hButton), DM_SETDEFID, buttonID, 0);
1266 break;
1267 }
1268
1269 /* Otherwise, set IDCANCEL as default button */
1270 case WM_KILLFOCUS:
1271 {
1273 break;
1274 }
1275 }
1276 return CallWindowProcW(pContext->OldButtonProc, hButton, uMsg, wParam, lParam);
1277}
1278
1279VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID)
1280{
1281 HWND hwndTool = NULL, hwndTip = NULL;
1282 WCHAR szBuffer[256];
1283 TTTOOLINFOW tool;
1284
1285 hwndTool = GetDlgItem(hDlg, controlID);
1286
1287 tool.cbSize = sizeof(tool);
1288 tool.hwnd = hDlg;
1290 tool.uId = (UINT_PTR)hwndTool;
1291
1292 /* Create the tooltip */
1293 hwndTip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL,
1297 hDlg, NULL, shell32_hInstance, NULL);
1298
1299 /* Associate the tooltip with the tool. */
1300 LoadStringW(shell32_hInstance, detailID, szBuffer, _countof(szBuffer));
1301 tool.lpszText = szBuffer;
1302 SendMessageW(hwndTip, TTM_ADDTOOLW, 0, (LPARAM)&tool);
1303 LoadStringW(shell32_hInstance, titleID, szBuffer, _countof(szBuffer));
1304 SendMessageW(hwndTip, TTM_SETTITLEW, TTI_NONE, (LPARAM)szBuffer);
1305 SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH, 0, 250);
1306}
1307
1309{
1310 DeleteObject(pContext->hBrush);
1311 DeleteObject(pContext->hImageStrip);
1312 DeleteObject(pContext->hfFont);
1313
1314 /* Remove the subclass from the buttons */
1315 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1316 {
1319 (LONG_PTR)pContext->OldButtonProc);
1320 }
1321}
1322
1324{
1325 DWORD dwType = 0, dwValue = 0, dwSize = 0;
1326 HKEY hKey = NULL;
1327 LONG lRet = 0;
1328
1330 L"SYSTEM\\CurrentControlSet\\Control\\Windows",
1331 0,
1333 &hKey);
1334 if (lRet != ERROR_SUCCESS)
1335 return FALSE;
1336
1337 /* First check an optional ReactOS specific override, that Windows does not check.
1338 We use this to allow users pairing 'Server'-configuration with FriendlyLogoff.
1339 Otherwise users would have to change CSDVersion or LogonType (side-effects AppCompat) */
1340 dwValue = 0;
1341 dwSize = sizeof(dwValue);
1342 lRet = RegQueryValueExW(hKey,
1343 L"EnforceFriendlyLogoff",
1344 NULL,
1345 &dwType,
1346 (LPBYTE)&dwValue,
1347 &dwSize);
1348
1349 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD && dwValue != FRIENDLY_LOGOFF_IS_NOT_ENFORCED)
1350 {
1352 return TRUE;
1353 }
1354
1355 /* Check product version number */
1356 dwValue = 0;
1357 dwSize = sizeof(dwValue);
1358 lRet = RegQueryValueExW(hKey,
1359 L"CSDVersion",
1360 NULL,
1361 &dwType,
1362 (LPBYTE)&dwValue,
1363 &dwSize);
1365
1366 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD || dwValue != IS_PRODUCT_VERSION_WORKSTATION)
1367 {
1368 /* Allow Friendly UI only on Workstation */
1369 return FALSE;
1370 }
1371
1372 /* Check LogonType value */
1374 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
1375 0,
1377 &hKey);
1378 if (lRet != ERROR_SUCCESS)
1379 return FALSE;
1380
1381 dwValue = 0;
1382 dwSize = sizeof(dwValue);
1383 lRet = RegQueryValueExW(hKey,
1384 L"LogonType",
1385 NULL,
1386 &dwType,
1387 (LPBYTE)&dwValue,
1388 &dwSize);
1390
1391 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
1392 return FALSE;
1393
1394 return (dwValue != 0);
1395}
1396
1398{
1399 HDC hdc = NULL;
1400 LONG lfHeight = NULL;
1401
1402 hdc = GetDC(NULL);
1404 ReleaseDC(NULL, hdc);
1405 pContext->hfFont = CreateFontW(lfHeight, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, L"MS Shell Dlg");
1407
1409
1411
1412 /* Gather old button func */
1414
1415 /* Set bIsButtonHot to false, create tooltips for each buttons and subclass the buttons */
1416 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1417 {
1418 pContext->bIsButtonHot[i] = FALSE;
1424 hwnd,
1426 }
1427}
1428
1429/*************************************************************************
1430 * LogOffDialogProc
1431 *
1432 * NOTES: Used to make the Log Off dialog work
1433 */
1435{
1437 PLOGOFF_DLG_CONTEXT pContext;
1439
1440 switch (uMsg)
1441 {
1442 case WM_INITDIALOG:
1443 {
1444 pContext = (PLOGOFF_DLG_CONTEXT)lParam;
1446
1447 if (pContext->bFriendlyUI)
1448 FancyLogoffOnInit(hwnd, pContext);
1449 return TRUE;
1450 }
1451
1452 case WM_CLOSE:
1454 break;
1455
1456 /*
1457 * If the user deactivates the log off dialog (it loses its focus
1458 * while the dialog is not being closed), then destroy the dialog
1459 * box.
1460 */
1461 case WM_ACTIVATE:
1462 {
1463 if (LOWORD(wParam) == WA_INACTIVE)
1464 {
1466 }
1467 return FALSE;
1468 }
1469
1470 case WM_COMMAND:
1471 switch (LOWORD(wParam))
1472 {
1473 case IDC_LOG_OFF_BUTTON:
1474 case IDOK:
1476 break;
1477
1478 case IDCANCEL:
1480 break;
1481 }
1482 break;
1483
1484 case WM_DESTROY:
1485 if (pContext->bFriendlyUI)
1486 EndFriendlyDialog(hwnd, pContext);
1487 return TRUE;
1488
1489 case WM_CTLCOLORSTATIC:
1490 {
1491 /* Either make background transparent or fill it with color for required static controls */
1492 HDC hdcStatic = (HDC)wParam;
1494
1495 switch (StaticID)
1496 {
1498 SetTextColor(hdcStatic, DARK_GREY_COLOR);
1499 SetBkMode(hdcStatic, TRANSPARENT);
1501
1502 case IDC_LOG_OFF_STATIC:
1504 SetTextColor(hdcStatic, LIGHT_GREY_COLOR);
1505 SetBkMode(hdcStatic, TRANSPARENT);
1506 return (LONG_PTR)pContext->hBrush;
1507 }
1508 return FALSE;
1509 }
1510 break;
1511
1512 case WM_DRAWITEM:
1513 {
1514 /* Draw bitmaps on required buttons */
1515 switch (pdis->CtlID)
1516 {
1517 case IDC_LOG_OFF_BUTTON:
1519 return DrawIconOnOwnerDrawnButtons(pdis, pContext);
1520 }
1521 }
1522 break;
1523
1524 default:
1525 break;
1526 }
1527 return FALSE;
1528}
1529
1530/*************************************************************************
1531 * LogoffWindowsDialog [SHELL32.54]
1532 */
1533
1535{
1536 CComPtr<IUnknown> fadeHandler;
1537 HWND parent = NULL;
1538 DWORD LogoffDialogID = IDD_LOG_OFF;
1540
1541 if (!CallShellDimScreen(&fadeHandler, &parent))
1542 parent = hWndOwner;
1543
1544 Context.bFriendlyUI = IsFriendlyUIActive();
1545 if (Context.bFriendlyUI)
1546 {
1547 LogoffDialogID = IDD_LOG_OFF_FANCY;
1548 }
1549
1551 MAKEINTRESOURCEW(LogoffDialogID),
1552 parent,
1554 (LPARAM)&Context);
1555 return 0;
1556}
1557
1558/*************************************************************************
1559 * RestartDialog [SHELL32.59]
1560 */
1561
1562int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags)
1563{
1564 return RestartDialogEx(hWndOwner, lpstrReason, uFlags, 0);
1565}
1566
1567/*************************************************************************
1568 * ExitWindowsDialog_backup
1569 *
1570 * NOTES
1571 * Used as a backup solution to shutdown the OS in case msgina.dll
1572 * somehow cannot be found.
1573 */
1575{
1576 TRACE("(%p)\n", hWndOwner);
1577
1579 {
1580 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1582 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1583 }
1584}
1585
1586/*************************************************************************
1587 * ExitWindowsDialog [SHELL32.60]
1588 *
1589 * NOTES
1590 * exported by ordinal
1591 */
1592/*
1593 * TODO:
1594 * - Implement the ability to show either the Welcome Screen or the classic dialog boxes based upon the
1595 * registry value: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LogonType.
1596 */
1598{
1599 typedef DWORD (WINAPI *ShellShFunc)(HWND hParent, WCHAR *Username, BOOL bHideLogoff);
1600 HINSTANCE msginaDll = LoadLibraryW(L"msgina.dll");
1601
1602 TRACE("(%p)\n", hWndOwner);
1603
1604 CComPtr<IUnknown> fadeHandler;
1605 HWND parent;
1606 if (!CallShellDimScreen(&fadeHandler, &parent))
1607 parent = hWndOwner;
1608
1609 /* If the DLL cannot be found for any reason, then it simply uses a
1610 dialog box to ask if the user wants to shut down the computer. */
1611 if (!msginaDll)
1612 {
1613 TRACE("Unable to load msgina.dll.\n");
1615 return;
1616 }
1617
1618 ShellShFunc pShellShutdownDialog = (ShellShFunc)GetProcAddress(msginaDll, "ShellShutdownDialog");
1619
1620 if (pShellShutdownDialog)
1621 {
1622 /* Actually call the function */
1623 DWORD returnValue = pShellShutdownDialog(parent, NULL, FALSE);
1624
1625 switch (returnValue)
1626 {
1627 case 0x01: /* Log off user */
1628 {
1630 break;
1631 }
1632 case 0x02: /* Shut down */
1633 {
1634 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1636 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1637 break;
1638 }
1639 case 0x03: /* Install Updates/Shutdown (?) */
1640 {
1641 break;
1642 }
1643 case 0x04: /* Reboot */
1644 {
1645 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1647 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1648 break;
1649 }
1650 case 0x10: /* Sleep */
1651 {
1652 if (IsPwrSuspendAllowed())
1653 {
1654 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1656 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1657 }
1658 break;
1659 }
1660 case 0x40: /* Hibernate */
1661 {
1663 {
1664 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1666 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1667 }
1668 break;
1669 }
1670 /* If the option is any other value */
1671 default:
1672 break;
1673 }
1674 }
1675 else
1676 {
1677 /* If the function cannot be found, then revert to using the backup solution */
1678 TRACE("Unable to find the 'ShellShutdownDialog' function");
1680 }
1681
1682 FreeLibrary(msginaDll);
1683}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
tShellDimScreen ShellDimScreen
#define shell32_hInstance
#define SECL_ALLOW_NONEXE
#define ShellExecCmdLine
#define SECL_NO_UI
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define index(s, c)
Definition: various.h:29
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
#define EXTERN_C
Definition: basetyps.h:12
#define RegCloseKey(hKey)
Definition: registry.h:49
WPARAM wParam
Definition: combotst.c:138
HWND hwndEdit
Definition: combotst.c:65
LPARAM lParam
Definition: combotst.c:139
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_ENABLESIZING
Definition: commdlg.h:101
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
wcscpy
HMODULE hLibrary
Definition: odbccp32.c:12
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT TitleId
Definition: desktop.c:52
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
UINT uFlags
Definition: api.c:59
HMODULE hModule
Definition: animate.c:44
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4736
static const WCHAR Title[]
Definition: oid.c:1259
#define CloseHandle
Definition: compat.h:739
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define wcsrchr
Definition: compat.h:16
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define FreeLibrary(x)
Definition: compat.h:748
#define GetCurrentProcess()
Definition: compat.h:759
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define LoadLibraryW(x)
Definition: compat.h:747
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
BOOL WINAPI EnumResourceNamesW(HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpfun, LONG_PTR lparam)
Definition: res.c:358
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
#define IDB_IMAGE_STRIP
Definition: resource.h:79
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define IDC_RUNDLG_BROWSE
Definition: resource.h:7
EXTERN_C int WINAPI LogoffWindowsDialog(HWND hWndOwner)
Definition: dialogs.cpp:1534
#define BUTTON_SWITCH_USER_DISABLED
Definition: dialogs.cpp:1114
VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID)
Definition: dialogs.cpp:1279
#define DARK_GREY_COLOR
Definition: dialogs.cpp:1098
BOOL CALLBACK EnumPickIconResourceProc(HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam)
Definition: dialogs.cpp:68
static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline)
Definition: dialogs.cpp:422
BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1120
static void FillList(HWND, LPWSTR, UINT, BOOL)
Definition: dialogs.cpp:777
int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
Definition: dialogs.cpp:1071
static void DestroyIconList(HWND hDlgCtrl, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:87
INT_PTR CALLBACK PickIconProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:185
static BOOL IsFriendlyUIActive(VOID)
Definition: dialogs.cpp:1323
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
Definition: dialogs.cpp:1041
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:351
#define CX_BITMAP
Definition: dialogs.cpp:1102
void WINAPI ExitWindowsDialog(HWND hWndOwner)
Definition: dialogs.cpp:1597
#define LOG_OFF_BUTTON_HOT
Definition: dialogs.cpp:1117
#define CX_ITEM
Definition: dialogs.cpp:182
VOID ExitWindowsDialog_backup(HWND hWndOwner)
Definition: dialogs.cpp:1574
#define BUTTON_SWITCH_USER
Definition: dialogs.cpp:1108
#define BUTTON_LOG_OFF_FOCUSED
Definition: dialogs.cpp:1113
static BOOL DoLoadIcons(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext, LPCWSTR pszFile)
Definition: dialogs.cpp:104
BOOL(WINAPI * LPFNOFN)(OPENFILENAMEW *)
Definition: dialogs.cpp:46
struct LOGOFF_DLG_CONTEXT * PLOGOFF_DLG_CONTEXT
VOID EndFriendlyDialog(HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1308
#define BUTTON_LOG_OFF
Definition: dialogs.cpp:1111
INT_PTR CALLBACK OwnerDrawButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1203
#define IS_PRODUCT_VERSION_WORKSTATION
Definition: dialogs.cpp:1093
BOOL CallShellDimScreen(IUnknown **pUnknown, HWND *hWindow)
Definition: dialogs.cpp:1021
#define NUMBER_OF_BUTTONS
Definition: dialogs.cpp:1105
static void EnableOkButtonFromEditContents(HWND hwnd)
Definition: dialogs.cpp:478
#define FONT_POINT_SIZE
Definition: dialogs.cpp:1096
static void NoIconsInFile(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:166
#define CY_BITMAP
Definition: dialogs.cpp:1103
INT_PTR CALLBACK LogOffDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1434
struct PICK_ICON_CONTEXT * PPICK_ICON_CONTEXT
#define CY_ITEM
Definition: dialogs.cpp:183
static VOID FancyLogoffOnInit(HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1397
#define CX_ICON
Definition: dialogs.cpp:178
#define SWITCH_USER_BUTTON_HOT
Definition: dialogs.cpp:1118
static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
Definition: dialogs.cpp:1008
#define LIGHT_GREY_COLOR
Definition: dialogs.cpp:1099
#define BUTTON_SWITCH_USER_PRESSED
Definition: dialogs.cpp:1109
#define BUTTON_LOG_OFF_PRESSED
Definition: dialogs.cpp:1112
#define FRIENDLY_LOGOFF_IS_NOT_ENFORCED
Definition: dialogs.cpp:1094
HRESULT(WINAPI * tShellDimScreen)(IUnknown **Unknown, HWND *hWindow)
Definition: dialogs.cpp:1018
#define BUTTON_SWITCH_USER_FOCUSED
Definition: dialogs.cpp:1110
static INT_PTR CALLBACK RunDlgProc(HWND, UINT, WPARAM, LPARAM)
Definition: dialogs.cpp:501
#define CY_ICON
Definition: dialogs.cpp:179
void WINAPI RunFileDlg(HWND hWndOwner, HICON hIcon, LPCWSTR lpstrDirectory, LPCWSTR lpstrTitle, LPCWSTR lpstrDescription, UINT uFlags)
Definition: dialogs.cpp:399
int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags)
Definition: dialogs.cpp:1562
#define ShellMessageBoxW
Definition: precomp.h:63
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1883
static const WCHAR Cleanup[]
Definition: register.c:80
#define pt(x, y)
Definition: drawing.c:79
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
r parent
Definition: btrfs.c:3010
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
LPCWSTR g_pszShell32
FxAutoRegKey hKey
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLenum src
Definition: glext.h:6340
GLuint index
Definition: glext.h:6031
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ Unknown
Definition: i8042prt.h:114
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:855
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define REG_SZ
Definition: layer.c:22
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define ASSERT(a)
Definition: mode.c:44
LPCWSTR szPath
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static char * dest
Definition: rtl.c:135
LPTSTR szFilter
Definition: mplay32.c:30
HICON hIcon
Definition: msconfig.c:44
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
unsigned int UINT
Definition: ndis.h:50
@ Initialized
Definition: ketypes.h:388
#define BOOL
Definition: nt_native.h:43
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DWORD
Definition: nt_native.h:44
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
#define L(x)
Definition: ntvdm.h:50
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
#define LOWORD(l)
Definition: pedump.c:82
#define WS_POPUP
Definition: pedump.c:616
long LONG
Definition: pedump.c:60
#define RT_GROUP_ICON
Definition: pedump.c:375
#define INT
Definition: polytest.cpp:20
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
Definition: powrprof.c:450
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
Definition: powrprof.c:792
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
#define TOOLTIPS_CLASSW
Definition: commctrl.h:1707
#define TTI_NONE
Definition: commctrl.h:1779
#define TTM_SETTITLEW
Definition: commctrl.h:1833
#define TTF_IDISHWND
Definition: commctrl.h:1764
#define TTF_SUBCLASS
Definition: commctrl.h:1767
#define TTM_ADDTOOLW
Definition: commctrl.h:1792
#define TTS_ALWAYSTIP
Definition: commctrl.h:1757
#define TTM_SETMAXTIPWIDTH
Definition: commctrl.h:1824
#define TTS_BALLOON
Definition: commctrl.h:1761
#define strlenW(s)
Definition: unicode.h:34
#define strcatW(d, s)
Definition: unicode.h:36
#define isspaceW(n)
Definition: unicode.h:58
#define WM_NOTIFY
Definition: richedit.h:61
#define RFF_NOBROWSE
Definition: run.h:33
#define RFF_NODEFAULT
Definition: run.h:34
#define RFF_CALCDIRECTORY
Definition: run.h:35
#define RFF_NOSEPARATEMEM
Definition: run.h:37
#define RFF_NOLABEL
Definition: run.h:36
#define REG_DWORD
Definition: sdbapi.c:596
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2474
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
Definition: autocomp.cpp:191
#define SHACF_FILESYSTEM
Definition: shlwapi.h:1957
#define SHACF_DEFAULT
Definition: shlwapi.h:1956
#define SHACF_FILESYS_ONLY
Definition: shlwapi.h:1962
#define SHACF_URLALL
Definition: shlwapi.h:1960
#define IDS_SHUTDOWN_TITLE
Definition: shresdef.h:82
#define IDI_SHELL_RUN
Definition: shresdef.h:603
#define IDS_LOG_OFF_TITLE
Definition: shresdef.h:382
#define IDS_NO_ICONS
Definition: shresdef.h:364
#define IDS_RESTART_TITLE
Definition: shresdef.h:80
#define IDD_PICK_ICON
Definition: shresdef.h:413
#define IDC_RUNDLG_LABEL
Definition: shresdef.h:393
#define IDC_LOG_OFF_BUTTON
Definition: shresdef.h:536
#define IDS_SHUTDOWN_PROMPT
Definition: shresdef.h:83
#define IDS_FILE_NOT_FOUND
Definition: shresdef.h:365
#define IDS_RUNDLG_BROWSE_FILTER
Definition: shresdef.h:198
#define IDC_LOG_OFF_TEXT_STATIC
Definition: shresdef.h:540
#define IDD_RUN
Definition: shresdef.h:388
#define IDC_EDIT_PATH
Definition: shresdef.h:416
#define IDC_LOG_OFF_STATIC
Definition: shresdef.h:538
#define IDC_PICKICON_LIST
Definition: shresdef.h:414
#define IDC_RUNDLG_EDITPATH
Definition: shresdef.h:392
#define IDC_RUNDLG_ICON
Definition: shresdef.h:391
#define IDS_RUNDLG_BROWSE_CAPTION
Definition: shresdef.h:197
#define IDD_LOG_OFF
Definition: shresdef.h:570
#define IDS_LOG_OFF_DESC
Definition: shresdef.h:380
#define IDC_BUTTON_PATH
Definition: shresdef.h:415
#define IDS_PICK_ICON_TITLE
Definition: shresdef.h:417
#define IDC_SWITCH_USER_BUTTON
Definition: shresdef.h:537
#define IDS_RUNDLG_BROWSE_ERROR
Definition: shresdef.h:196
#define IDC_RUNDLG_DESCRIPTION
Definition: shresdef.h:389
#define IDS_PICK_ICON_FILTER
Definition: shresdef.h:418
#define IDC_SWITCH_USER_STATIC
Definition: shresdef.h:539
#define IDD_LOG_OFF_FANCY
Definition: shresdef.h:576
#define IDS_RESTART_PROMPT
Definition: shresdef.h:81
OPENFILENAME ofn
Definition: sndrec32.cpp:56
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
& rect
Definition: startmenu.cpp:1413
TCHAR * cmdline
Definition: stretchblt.cpp:32
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
COM Initialisation.
Definition: shellclasses.h:179
WNDPROC OldButtonProc
Definition: dialogs.cpp:43
BOOL bIsButtonHot[2]
Definition: dialogs.cpp:39
HBITMAP hImageStrip
Definition: dialogs.cpp:40
HMODULE hLibrary
Definition: dialogs.cpp:60
WCHAR szPath[MAX_PATH]
Definition: dialogs.cpp:62
HICON * phIcons
Definition: dialogs.cpp:65
LPCWSTR lpstrDirectory
Definition: dialogs.cpp:29
LPCWSTR lpstrTitle
Definition: dialogs.cpp:30
LPCWSTR lpstrDescription
Definition: dialogs.cpp:31
LPCWSTR lpFile
Definition: undocshell.h:179
LPCWSTR lpDirectory
Definition: undocshell.h:180
HMODULE hLibrary
Definition: dialog.c:549
LPCWSTR lpDirectory
Definition: shellapi.h:341
Definition: tftpd.h:60
UINT_PTR idFrom
Definition: winuser.h:3169
UINT code
Definition: winuser.h:3170
HWND hwndFrom
Definition: winuser.h:3168
HWND hwndOwner
Definition: commdlg.h:330
LPCSTR lpstrTitle
Definition: commdlg.h:341
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
UINT_PTR uId
Definition: commctrl.h:1743
LPWSTR lpszText
Definition: commctrl.h:1746
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT_PTR
Definition: typedefs.h:64
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define MAKELONG(a, b)
Definition: typedefs.h:249
uint16_t * PWCHAR
Definition: typedefs.h:56
#define HIWORD(l)
Definition: typedefs.h:247
#define RF_OK
Definition: undocshell.h:189
#define RFN_VALIDATE
Definition: undocshell.h:166
#define RF_RETRY
Definition: undocshell.h:191
#define RF_CANCEL
Definition: undocshell.h:190
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_In_ WDFCOLLECTION _In_ ULONG Index
HDC hdcMem
Definition: welcome.c:104
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
#define ZeroMemory
Definition: winbase.h:1744
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:369
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define DI_NORMAL
Definition: wingdi.h:72
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define TRANSPARENT
Definition: wingdi.h:950
#define HOLLOW_BRUSH
Definition: wingdi.h:899
#define SRCCOPY
Definition: wingdi.h:333
HFONT WINAPI CreateFontW(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCWSTR)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
#define FW_MEDIUM
Definition: wingdi.h:375
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define SW_SHOWNORMAL
Definition: winuser.h:781
#define ODS_DISABLED
Definition: winuser.h:2558
#define LB_ERR
Definition: winuser.h:2443
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
HWND WINAPI SetCapture(_In_ HWND hWnd)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define MAKEWPARAM(l, h)
Definition: winuser.h:4020
#define EWX_SHUTDOWN
Definition: winuser.h:647
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1783
#define LB_GETCOUNT
Definition: winuser.h:2049
#define ODS_SELECTED
Definition: winuser.h:2556
#define SW_HIDE
Definition: winuser.h:779
#define LB_FINDSTRINGEXACT
Definition: winuser.h:2046
#define WM_CLOSE
Definition: winuser.h:1632
#define DM_SETDEFID
Definition: winuser.h:2110
#define DWLP_USER
Definition: winuser.h:883
#define GetWindowLongPtrW
Definition: winuser.h:4840
#define MAKELPARAM(l, h)
Definition: winuser.h:4019
#define COLOR_WINDOW
Definition: winuser.h:929
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
struct tagMEASUREITEMSTRUCT * LPMEASUREITEMSTRUCT
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define ODA_DRAWENTIRE
Definition: winuser.h:2553
#define STM_SETICON
Definition: winuser.h:2103
#define IDCANCEL
Definition: winuser.h:842
#define LB_SETTOPINDEX
Definition: winuser.h:2081
#define LBN_DBLCLK
Definition: winuser.h:2082
#define GWL_ID
Definition: winuser.h:870
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
#define WM_COMMAND
Definition: winuser.h:1751
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define ODA_FOCUS
Definition: winuser.h:2555
#define EWX_LOGOFF
Definition: winuser.h:644
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_SETFOCUS
Definition: winuser.h:1624
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_MOUSEMOVE
Definition: winuser.h:1786
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define WA_INACTIVE
Definition: winuser.h:2633
#define CB_RESETCONTENT
Definition: winuser.h:1970
#define WM_INITDIALOG
Definition: winuser.h:1750
#define MB_YESNO
Definition: winuser.h:828
#define LB_ADDSTRING
Definition: winuser.h:2042
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2442
#define LB_SETCOLUMNWIDTH
Definition: winuser.h:2072
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:841
#define WM_DRAWITEM
Definition: winuser.h:1656
#define CBN_SELCHANGE
Definition: winuser.h:1990
#define WM_ACTIVATE
Definition: winuser.h:1623
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_ICONERROR
Definition: winuser.h:798
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define EWX_REBOOT
Definition: winuser.h:646
#define LB_RESETCONTENT
Definition: winuser.h:2066
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI GetComboBoxInfo(_In_ HWND, _Inout_ PCOMBOBOXINFO)
#define WM_SETFONT
Definition: winuser.h:1661
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:2365
#define CB_ADDSTRING
Definition: winuser.h:1947
#define SendMessage
Definition: winuser.h:5863
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HDC WINAPI GetDC(_In_opt_ HWND)
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define MB_OK
Definition: winuser.h:801
#define WM_MEASUREITEM
Definition: winuser.h:1657
#define CB_SETEDITSEL
Definition: winuser.h:1974
#define MB_ICONWARNING
Definition: winuser.h:797
#define PostMessage
Definition: winuser.h:5852
#define CW_USEDEFAULT
Definition: winuser.h:225
HWND WINAPI GetParent(_In_ HWND)
#define LBN_SELCHANGE
Definition: winuser.h:2086
#define ODA_SELECT
Definition: winuser.h:2554
#define MB_ICONQUESTION
Definition: winuser.h:800
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
HWND WINAPI WindowFromPoint(_In_ POINT)
int WINAPI GetDlgCtrlID(_In_ HWND)
#define IDC_HAND
Definition: winuser.h:706
#define SW_SHOW
Definition: winuser.h:786
#define WM_DESTROY
Definition: winuser.h:1620
#define LB_SETCURSEL
Definition: winuser.h:2074
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define CB_INSERTSTRING
Definition: winuser.h:1968
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2917
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2500
#define IDYES
Definition: winuser.h:846
#define LB_GETCURSEL
Definition: winuser.h:2050
#define SetWindowLongPtrW
Definition: winuser.h:5366
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_KILLFOCUS
Definition: winuser.h:1625
#define ODS_FOCUS
Definition: winuser.h:2560
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2412
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CBN_EDITCHANGE
Definition: winuser.h:1986
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2390
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185