ReactOS 0.4.16-dev-1946-g52006dd
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;
46
48
51static void FillList(HWND, LPWSTR, UINT, BOOL);
52
53
54/*************************************************************************
55 * PickIconDlg [SHELL32.62]
56 *
57 */
58
59typedef struct
60{
68
70 LPCWSTR lpszType,
71 LPWSTR lpszName,
73{
75 HWND hDlgCtrl = pIconContext->hDlgCtrl;
76
77 if (IS_INTRESOURCE(lpszName))
78 lParam = LOWORD(lpszName);
79 else
80 lParam = -1;
81
82 SendMessageW(hDlgCtrl, LB_ADDSTRING, 0, lParam);
83
84 return TRUE;
85}
86
87static void
89{
90 int count;
91 int index;
92
93 count = SendMessageW(hDlgCtrl, LB_GETCOUNT, 0, 0);
94 if (count == LB_ERR)
95 return;
96
97 for(index = 0; index < count; index++)
98 {
99 DestroyIcon(pIconContext->phIcons[index]);
100 pIconContext->phIcons[index] = NULL;
101 }
102}
103
104static BOOL
105DoLoadIcons(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext, LPCWSTR pszFile)
106{
107 WCHAR szExpandedPath[MAX_PATH];
108
109 // Destroy previous icons
110 DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
111 SendMessageW(pIconContext->hDlgCtrl, LB_RESETCONTENT, 0, 0);
112 delete[] pIconContext->phIcons;
113
114 // Store the path
115 StringCchCopyW(pIconContext->szPath, _countof(pIconContext->szPath), pszFile);
116 ExpandEnvironmentStringsW(pszFile, szExpandedPath, _countof(szExpandedPath));
117
118 // Load the module if possible
120 if (pIconContext->hLibrary)
121 FreeLibrary(pIconContext->hLibrary);
122 pIconContext->hLibrary = hLibrary;
123
124 if (pIconContext->hLibrary)
125 {
126 // Load the icons from the module
127 pIconContext->nIcons = ExtractIconExW(szExpandedPath, -1, NULL, NULL, 0);
128 pIconContext->phIcons = new HICON[pIconContext->nIcons];
129
130 if (ExtractIconExW(szExpandedPath, 0, pIconContext->phIcons, NULL, pIconContext->nIcons))
131 {
133 }
134 else
135 {
136 pIconContext->nIcons = 0;
137 }
138 }
139 else
140 {
141 // .ico file
142 pIconContext->nIcons = 1;
143 pIconContext->phIcons = new HICON[1];
144
145 if (ExtractIconExW(szExpandedPath, 0, pIconContext->phIcons, NULL, pIconContext->nIcons))
146 {
147 SendMessageW(pIconContext->hDlgCtrl, LB_ADDSTRING, 0, 0);
148 }
149 else
150 {
151 pIconContext->nIcons = 0;
152 }
153 }
154
155 SetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath);
156 SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
157
158 if (pIconContext->nIcons == 0)
159 {
160 delete[] pIconContext->phIcons;
161 pIconContext->phIcons = NULL;
162 }
163
164 return (pIconContext->nIcons > 0);
165}
166
167static void NoIconsInFile(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext)
168{
169 // Show an error message
170 CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
171 strText.Format(IDS_NO_ICONS, pIconContext->szPath);
172 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONWARNING);
173
174 // Load the default icons
175 DoLoadIcons(hwndDlg, pIconContext, g_pszShell32);
176}
177
178// Icon size
179#define CX_ICON GetSystemMetrics(SM_CXICON)
180#define CY_ICON GetSystemMetrics(SM_CYICON)
181
182// Item size
183#define CX_ITEM (CX_ICON + 4)
184#define CY_ITEM (CY_ICON + 12)
185
187 HWND hwndDlg,
188 UINT uMsg,
191{
193 LPDRAWITEMSTRUCT lpdis;
194 HICON hIcon;
195 INT index, count;
196 WCHAR szText[MAX_PATH], szFilter[100];
199
200 switch(uMsg)
201 {
202 case WM_INITDIALOG:
203 {
204 pIconContext = (PPICK_ICON_CONTEXT)lParam;
205 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pIconContext);
206 pIconContext->hDlgCtrl = GetDlgItem(hwndDlg, IDC_PICKICON_LIST);
207
208 SendMessageW(pIconContext->hDlgCtrl, LB_SETCOLUMNWIDTH, CX_ITEM, 0);
209
210 // Load the icons
211 if (!DoLoadIcons(hwndDlg, pIconContext, pIconContext->szPath))
212 NoIconsInFile(hwndDlg, pIconContext);
213
214 // Set the selection
215 count = SendMessageW(pIconContext->hDlgCtrl, LB_GETCOUNT, 0, 0);
216 if (count != LB_ERR)
217 {
218 if (pIconContext->Index < 0)
219 {
220 // A negative value will be interpreted as a negated resource ID.
221 LPARAM lParam = -pIconContext->Index;
222 pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_FINDSTRINGEXACT, -1, lParam);
223 }
224
225 if (pIconContext->Index < 0 || count <= pIconContext->Index)
226 pIconContext->Index = 0;
227
228 SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, pIconContext->Index, 0);
229 SendMessageW(pIconContext->hDlgCtrl, LB_SETTOPINDEX, pIconContext->Index, 0);
230 }
231
233 return TRUE;
234 }
235
236 case WM_DESTROY:
237 {
238 DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
239 delete[] pIconContext->phIcons;
240
241 if (pIconContext->hLibrary)
242 FreeLibrary(pIconContext->hLibrary);
243 break;
244 }
245
246 case WM_COMMAND:
247 switch(LOWORD(wParam))
248 {
249 case IDOK:
250 {
251 /* Check whether the path edit control has been modified; if so load the icons instead of validating */
252 GetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, szText, _countof(szText));
253 if (lstrcmpiW(szText, pIconContext->szPath))
254 {
255 if (!DoLoadIcons(hwndDlg, pIconContext, szText))
256 NoIconsInFile(hwndDlg, pIconContext);
257 break;
258 }
259
260 /* The path edit control has not been modified, return the selection */
261 pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
262 GetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath, _countof(pIconContext->szPath));
263 EndDialog(hwndDlg, 1);
264 break;
265 }
266
267 case IDCANCEL:
268 EndDialog(hwndDlg, 0);
269 break;
270
272 switch (HIWORD(wParam))
273 {
274 case LBN_SELCHANGE:
276 break;
277
278 case LBN_DBLCLK:
279 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);
280 break;
281 }
282 break;
283
284 case IDC_BUTTON_PATH:
285 {
286 // Choose the module path
287 CStringW strTitle;
288 szText[0] = 0;
289 szFilter[0] = 0;
290 ZeroMemory(&ofn, sizeof(ofn));
291 ofn.lStructSize = sizeof(ofn);
292 ofn.hwndOwner = hwndDlg;
293 ofn.lpstrFile = szText;
294 ofn.nMaxFile = _countof(szText);
295 strTitle.LoadString(IDS_PICK_ICON_TITLE);
296 ofn.lpstrTitle = strTitle;
299 if (!GetOpenFileNameW(&ofn))
300 break;
301
302 // Load the icons
303 if (!DoLoadIcons(hwndDlg, pIconContext, szText))
304 NoIconsInFile(hwndDlg, pIconContext);
305 break;
306 }
307
308 default:
309 break;
310 }
311 break;
312
313 case WM_MEASUREITEM:
315 lpmis->itemHeight = CY_ITEM;
316 return TRUE;
317
318 case WM_DRAWITEM:
319 {
320 lpdis = (LPDRAWITEMSTRUCT)lParam;
321 if (lpdis->itemID == (UINT)-1)
322 break;
323 switch (lpdis->itemAction) // FIXME: MSDN says that more than one of these can be set
324 {
325 // FIXME: ODA_FOCUS
326 case ODA_SELECT:
327 case ODA_DRAWENTIRE:
328 {
329 index = SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
330 hIcon = pIconContext->phIcons[lpdis->itemID];
331
332 if (lpdis->itemID == (UINT)index)
333 FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
334 else
335 FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
336
337 // Centering
338 INT x = lpdis->rcItem.left + (CX_ITEM - CX_ICON) / 2;
339 INT y = lpdis->rcItem.top + (CY_ITEM - CY_ICON) / 2;
340
341 DrawIconEx(lpdis->hDC, x, y, hIcon, 0, 0, 0, NULL, DI_NORMAL);
342 break;
343 }
344 }
345 return TRUE;
346 }
347 }
348
349 return FALSE;
350}
351
353 HWND hWndOwner,
354 LPWSTR lpstrFile,
355 UINT nMaxFile,
356 INT* lpdwIconIndex)
357{
358 CCoInit ComInit; // For SHAutoComplete (CORE-20030)
359 int res;
360 WCHAR szExpandedPath[MAX_PATH];
361
362 // Initialize the dialog
363 PICK_ICON_CONTEXT IconContext = {0};
364 IconContext.Index = *lpdwIconIndex;
365 StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), lpstrFile);
366 ExpandEnvironmentStringsW(lpstrFile, szExpandedPath, _countof(szExpandedPath));
367
368 if (!szExpandedPath[0] ||
370 {
371 if (szExpandedPath[0])
372 {
373 // No such file
374 CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
375 strText.Format(IDS_FILE_NOT_FOUND, lpstrFile);
376 MessageBoxW(hWndOwner, strText, strTitle, MB_ICONWARNING);
377 }
378
379 // Set the default value
380 StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), g_pszShell32);
381 }
382
383 // Show the dialog
385 if (res)
386 {
387 // Store the selected icon
388 StringCchCopyW(lpstrFile, nMaxFile, IconContext.szPath);
389 *lpdwIconIndex = IconContext.Index;
390 }
391
392 return res;
393}
394
395/*************************************************************************
396 * RunFileDlg [internal]
397 *
398 * The Unicode function that is available as ordinal 61 on Windows NT/2000/XP/...
399 */
401 HWND hWndOwner,
402 HICON hIcon,
403 LPCWSTR lpstrDirectory,
404 LPCWSTR lpstrTitle,
405 LPCWSTR lpstrDescription,
406 UINT uFlags)
407{
408 TRACE("\n");
409
410 RUNFILEDLGPARAMS rfdp;
411 rfdp.hwndOwner = hWndOwner;
412 rfdp.hIcon = hIcon;
413 rfdp.lpstrDirectory = lpstrDirectory;
414 rfdp.lpstrTitle = lpstrTitle;
415 rfdp.lpstrDescription = lpstrDescription;
416 rfdp.uFlags = uFlags;
417
419}
420
421
422/* find the directory that contains the file being run */
424{
425 const WCHAR *src;
426 WCHAR *dest, *result, *result_end=NULL;
427
428 result = (WCHAR *)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(strlenW(cmdline)+5));
429
430 if (NULL == result)
431 {
432 TRACE("HeapAlloc couldn't allocate %d bytes\n", sizeof(WCHAR)*(strlenW(cmdline)+5));
433 return NULL;
434 }
435
436 src = cmdline;
437 dest = result;
438
439 if (*src == '"')
440 {
441 src++;
442 while (*src && *src != '"')
443 {
444 if (*src == '\\')
445 result_end = dest;
446 *dest++ = *src++;
447 }
448 }
449 else {
450 while (*src)
451 {
452 if (isspaceW(*src))
453 {
454 *dest = 0;
456 break;
457 strcatW(dest, L".exe");
459 break;
460 }
461 else if (*src == '\\')
462 result_end = dest;
463 *dest++ = *src++;
464 }
465 }
466
467 if (result_end)
468 {
469 *result_end = 0;
470 return result;
471 }
472 else
473 {
475 return NULL;
476 }
477}
478
480{
481 BOOL Enable = FALSE;
482 INT Length, n;
485 if (Length > 0)
486 {
487 PWCHAR psz = (PWCHAR)HeapAlloc(GetProcessHeap(), 0, (Length + 1) * sizeof(WCHAR));
488 if (psz)
489 {
490 GetWindowTextW(Edit, psz, Length + 1);
491 for (n = 0; n < Length && !Enable; ++n)
492 Enable = psz[n] != ' ';
493 HeapFree(GetProcessHeap(), 0, psz);
494 }
495 else
496 Enable = TRUE;
497 }
499}
500
501/* Dialog procedure for RunFileDlg */
503{
505 HWND hwndCombo, hwndEdit;
506 COMBOBOXINFO ComboInfo;
507
508 switch (message)
509 {
510 case WM_INITDIALOG:
511 prfdp = (RUNFILEDLGPARAMS *)lParam;
513
514 if (prfdp->lpstrTitle)
515 SetWindowTextW(hwnd, prfdp->lpstrTitle);
516 if (prfdp->lpstrDescription)
517 SetWindowTextW(GetDlgItem(hwnd, IDC_RUNDLG_DESCRIPTION), prfdp->lpstrDescription);
518 if (prfdp->uFlags & RFF_NOBROWSE)
519 {
521 ShowWindow(browse, SW_HIDE);
522 EnableWindow(browse, FALSE);
523 }
524 if (prfdp->uFlags & RFF_NOLABEL)
526 if (prfdp->uFlags & RFF_NOSEPARATEMEM)
527 {
528 FIXME("RFF_NOSEPARATEMEM not supported\n");
529 }
530
531 /* Use the default Shell Run icon if no one is specified */
532 if (prfdp->hIcon == NULL)
534 /*
535 * NOTE: Starting Windows Vista, the "Run File" dialog gets a
536 * title icon that remains the same as the default one, even if
537 * the user specifies a custom icon.
538 * Since we currently imitate Windows 2003, therefore do not show
539 * any title icon.
540 */
541 // SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM)prfdp->hIcon);
542 // SendMessageW(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)prfdp->hIcon);
544
545 hwndCombo = GetDlgItem(hwnd, IDC_RUNDLG_EDITPATH);
546 FillList(hwndCombo, NULL, 0, (prfdp->uFlags & RFF_NODEFAULT) == 0);
548
549 ComboInfo.cbSize = sizeof(ComboInfo);
550 GetComboBoxInfo(hwndCombo, &ComboInfo);
551 hwndEdit = ComboInfo.hwndItem;
553
554 // SHAutoComplete needs co init
556
558
559 SetFocus(hwndCombo);
560 return TRUE;
561
562 case WM_DESTROY:
563 if (prfdp->bCoInited)
565 break;
566
567 case WM_COMMAND:
568 switch (LOWORD(wParam))
569 {
570 case IDOK:
571 {
572 LRESULT lRet;
574 INT ic;
575 WCHAR *psz, *pszExpanded, *parent = NULL;
576 DWORD cchExpand;
577 SHELLEXECUTEINFOW sei = { sizeof(sei) };
578 NMRUNFILEDLGW nmrfd;
579
580 ic = GetWindowTextLengthW(htxt);
581 if (ic == 0)
582 {
584 return TRUE;
585 }
586
587 /*
588 * Allocate a new MRU entry, we need to add two characters
589 * for the terminating "\\1" part, then the NULL character.
590 */
591 psz = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (ic + 2 + 1)*sizeof(WCHAR));
592 if (!psz)
593 {
595 return TRUE;
596 }
597
598 GetWindowTextW(htxt, psz, ic + 1);
599 sei.hwnd = hwnd;
600 sei.nShow = SW_SHOWNORMAL;
601 sei.lpFile = psz;
602 StrTrimW(psz, L" \t");
603
604 if (wcschr(psz, L'%') != NULL)
605 {
606 cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0);
607 pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR));
608 if (!pszExpanded)
609 {
610 HeapFree(GetProcessHeap(), 0, psz);
612 return TRUE;
613 }
614 ExpandEnvironmentStringsW(psz, pszExpanded, cchExpand);
615 StrTrimW(pszExpanded, L" \t");
616 }
617 else
618 {
619 pszExpanded = psz;
620 }
621
622 /*
623 * The precedence is the following: first the user-given
624 * current directory is used; if there is none, a current
625 * directory is computed if the RFF_CALCDIRECTORY is set,
626 * otherwise no current directory is defined.
627 */
628 LPCWSTR pszStartDir;
629 if (prfdp->lpstrDirectory)
630 {
631 sei.lpDirectory = prfdp->lpstrDirectory;
632 pszStartDir = prfdp->lpstrDirectory;
633 }
634 else if (prfdp->uFlags & RFF_CALCDIRECTORY)
635 {
637 pszStartDir = parent = RunDlg_GetParentDir(pszExpanded);
638 }
639 else
640 {
641 sei.lpDirectory = NULL;
642 pszStartDir = NULL;
643 }
644
645 /* Hide the dialog for now on, we will show it up in case of retry */
647
648 /*
649 * As shown by manual tests on Windows, modifying the contents
650 * of the notification structure will not modify what the
651 * Run-Dialog will use for the nShow parameter. However the
652 * lpFile and lpDirectory pointers are set to the buffers used
653 * by the Run-Dialog, as a consequence they can be modified by
654 * the notification receiver, as long as it respects the lengths
655 * of the buffers (to avoid buffer overflows).
656 */
657 nmrfd.hdr.code = RFN_VALIDATE;
658 nmrfd.hdr.hwndFrom = hwnd;
659 nmrfd.hdr.idFrom = 0;
660 nmrfd.lpFile = pszExpanded;
661 nmrfd.lpDirectory = pszStartDir;
662 nmrfd.nShow = SW_SHOWNORMAL;
663
664 lRet = SendMessageW(prfdp->hwndOwner, WM_NOTIFY, 0, (LPARAM)&nmrfd.hdr);
665
666 switch (lRet)
667 {
668 case RF_CANCEL:
670 break;
671
672 case RF_OK:
673 /* We use SECL_NO_UI because we don't want to see
674 * errors here, but we will try again below and
675 * there we will output our errors. */
676 if (SUCCEEDED(ShellExecCmdLine(hwnd, pszExpanded, pszStartDir, SW_SHOWNORMAL, NULL,
678 {
679 /* Call GetWindowText again in case the contents of the edit box have changed. */
680 GetWindowTextW(htxt, psz, ic + 1);
681 FillList(htxt, psz, ic + 2 + 1, FALSE);
683 break;
684 }
685 else if (ShellExecuteExW(&sei))
686 {
687 /* Call GetWindowText again in case the contents of the edit box have changed. */
688 GetWindowTextW(htxt, psz, ic + 1);
689 FillList(htxt, psz, ic + 2 + 1, FALSE);
691 break;
692 }
693
694 /* Fall-back */
695 case RF_RETRY:
696 default:
697 SendMessageW(htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
698 /* Show back the dialog */
700 break;
701 }
702
704 HeapFree(GetProcessHeap(), 0, psz);
705 if (psz != pszExpanded)
706 HeapFree(GetProcessHeap(), 0, pszExpanded);
707 return TRUE;
708 }
709
710 case IDCANCEL:
712 return TRUE;
713
715 {
716 HMODULE hComdlg = NULL;
717 LPFNOFN ofnProc = NULL;
718 WCHAR szFName[1024] = {0};
719 WCHAR filter[MAX_PATH], szCaption[MAX_PATH];
721
724
725 ZeroMemory(&ofn, sizeof(ofn));
726 ofn.lStructSize = sizeof(ofn);
729 ofn.lpstrFile = szFName;
730 ofn.nMaxFile = _countof(szFName) - 1;
731 ofn.lpstrTitle = szCaption;
733 ofn.lpstrInitialDir = prfdp->lpstrDirectory;
734
735 if (NULL == (hComdlg = LoadLibraryExW(L"comdlg32", NULL, 0)) ||
736 NULL == (ofnProc = (LPFNOFN)GetProcAddress(hComdlg, "GetOpenFileNameW")))
737 {
738 ERR("Couldn't get GetOpenFileName function entry (lib=%p, proc=%p)\n", hComdlg, ofnProc);
740 return TRUE;
741 }
742
743 if (ofnProc(&ofn))
744 {
750 }
751
752 FreeLibrary(hComdlg);
753
754 return TRUE;
755 }
757 {
760
761 // Delay handling dropdown changes until the edit box has been updated.
764 return TRUE;
765 }
766 }
767 return TRUE;
768 }
769 return FALSE;
770}
771
772/*
773 * This function grabs the MRU list from the registry and fills the combo-list
774 * for the "Run" dialog above. fShowDefault is ignored if pszLatest != NULL.
775 */
776// FIXME: Part of this code should be part of some MRUList API,
777// that is scattered amongst shell32, comctl32 (?!) and comdlg32.
778static void FillList(HWND hCb, LPWSTR pszLatest, UINT cchStr, BOOL fShowDefault)
779{
780 HKEY hkey;
781 WCHAR *pszList = NULL, *pszCmd = NULL, *pszTmp = NULL, cMatch = 0, cMax = 0x60;
782 WCHAR szIndex[2] = L"-";
783 UINT cchLatest;
784 DWORD dwType, icList = 0, icCmd = 0;
785 LRESULT lRet;
786 UINT Nix;
787
788 /*
789 * Retrieve the string length of pszLatest and check whether its buffer size
790 * (cchStr in number of characters) is large enough to add the terminating "\\1"
791 * (and the NULL character).
792 */
793 if (pszLatest)
794 {
795 cchLatest = wcslen(pszLatest);
796 if (cchStr < cchLatest + 2 + 1)
797 {
798 TRACE("pszLatest buffer is not large enough (%d) to hold the MRU terminator.\n", cchStr);
799 return;
800 }
801 }
802 else
803 {
804 cchStr = 0;
805 }
806
807 SendMessageW(hCb, CB_RESETCONTENT, 0, 0);
808
810 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU",
812 if (lRet != ERROR_SUCCESS)
813 {
814 TRACE("Unable to open or create the RunMRU key, error %d\n", GetLastError());
815 return;
816 }
817
818 lRet = RegQueryValueExW(hkey, L"MRUList", NULL, &dwType, NULL, &icList);
819 if (lRet == ERROR_SUCCESS && dwType == REG_SZ && icList > sizeof(WCHAR))
820 {
821 pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icList);
822 if (!pszList)
823 {
824 TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
825 goto Continue;
826 }
827 pszList[0] = L'\0';
828
829 lRet = RegQueryValueExW(hkey, L"MRUList", NULL, NULL, (LPBYTE)pszList, &icList);
830 if (lRet != ERROR_SUCCESS)
831 {
832 TRACE("Unable to grab MRUList, error %d\n", GetLastError());
833 pszList[0] = L'\0';
834 }
835 }
836 else
837 {
838Continue:
839 icList = sizeof(WCHAR);
840 pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icList);
841 if (!pszList)
842 {
843 TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
844 RegCloseKey(hkey);
845 return;
846 }
847 pszList[0] = L'\0';
848 }
849
850 /* Convert the number of bytes from MRUList into number of characters (== number of indices) */
851 icList /= sizeof(WCHAR);
852
853 for (Nix = 0; Nix < icList - 1; Nix++)
854 {
855 if (pszList[Nix] > cMax)
856 cMax = pszList[Nix];
857
858 szIndex[0] = pszList[Nix];
859
860 lRet = RegQueryValueExW(hkey, szIndex, NULL, &dwType, NULL, &icCmd);
861 if (lRet != ERROR_SUCCESS || dwType != REG_SZ)
862 {
863 TRACE("Unable to grab size of index, error %d\n", GetLastError());
864 continue;
865 }
866
867 if (pszCmd)
868 {
869 pszTmp = (WCHAR*)HeapReAlloc(GetProcessHeap(), 0, pszCmd, icCmd);
870 if (!pszTmp)
871 {
872 TRACE("HeapReAlloc failed to reallocate %d bytes\n", icCmd);
873 continue;
874 }
875 pszCmd = pszTmp;
876 }
877 else
878 {
879 pszCmd = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icCmd);
880 if (!pszCmd)
881 {
882 TRACE("HeapAlloc failed to allocate %d bytes\n", icCmd);
883 continue;
884 }
885 }
886
887 lRet = RegQueryValueExW(hkey, szIndex, NULL, NULL, (LPBYTE)pszCmd, &icCmd);
888 if (lRet != ERROR_SUCCESS)
889 {
890 TRACE("Unable to grab index, error %d\n", GetLastError());
891 continue;
892 }
893
894 /*
895 * Generally the command string will end up with "\\1".
896 * Find the last backslash in the string and NULL-terminate.
897 * Windows does not seem to check for what comes next, so that
898 * a command of the form:
899 * c:\\my_dir\\myfile.exe
900 * will be cut just after "my_dir", whereas a command of the form:
901 * c:\\my_dir\\myfile.exe\\1
902 * will be cut just after "myfile.exe".
903 */
904 pszTmp = wcsrchr(pszCmd, L'\\');
905 if (pszTmp)
906 *pszTmp = L'\0';
907
908 /*
909 * In the following we try to add pszLatest to the MRU list.
910 * We suppose that our caller has already correctly allocated
911 * the string with enough space for us to append a "\\1".
912 *
913 * FIXME: TODO! (At the moment we don't append it!)
914 */
915
916 if (pszLatest)
917 {
918 if (_wcsicmp(pszCmd, pszLatest) == 0)
919 {
920 SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszCmd);
921 SetWindowTextW(hCb, pszCmd);
922 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
923
924 cMatch = pszList[Nix];
925 memmove(&pszList[1], pszList, Nix * sizeof(WCHAR));
926 pszList[0] = cMatch;
927 continue;
928 }
929 }
930
931 if (icList - 1 != 26 || icList - 2 != Nix || cMatch || pszLatest == NULL)
932 {
933 SendMessageW(hCb, CB_ADDSTRING, 0, (LPARAM)pszCmd);
934 if (!Nix && fShowDefault)
935 {
936 SetWindowTextW(hCb, pszCmd);
937 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
938 }
939 }
940 else
941 {
942 SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest);
943 SetWindowTextW(hCb, pszLatest);
944 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
945
946 cMatch = pszList[Nix];
947 memmove(&pszList[1], pszList, Nix * sizeof(WCHAR));
948 pszList[0] = cMatch;
949 szIndex[0] = cMatch;
950
951 wcscpy(&pszLatest[cchLatest], L"\\1");
952 RegSetValueExW(hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, (cchLatest + 2 + 1) * sizeof(WCHAR));
953 pszLatest[cchLatest] = L'\0';
954 }
955 }
956
957 if (!cMatch && pszLatest != NULL)
958 {
959 SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest);
960 SetWindowTextW(hCb, pszLatest);
961 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
962
963 cMatch = ++cMax;
964
965 if (pszList)
966 {
967 pszTmp = (WCHAR*)HeapReAlloc(GetProcessHeap(), 0, pszList, (++icList) * sizeof(WCHAR));
968 if (!pszTmp)
969 {
970 TRACE("HeapReAlloc failed to reallocate enough bytes\n");
971 goto Cleanup;
972 }
973 pszList = pszTmp;
974 }
975 else
976 {
977 pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (++icList) * sizeof(WCHAR));
978 if (!pszList)
979 {
980 TRACE("HeapAlloc failed to allocate enough bytes\n");
981 goto Cleanup;
982 }
983 }
984
985 memmove(&pszList[1], pszList, (icList - 1) * sizeof(WCHAR));
986 pszList[0] = cMatch;
987 szIndex[0] = cMatch;
988
989 wcscpy(&pszLatest[cchLatest], L"\\1");
990 RegSetValueExW(hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, (cchLatest + 2 + 1) * sizeof(WCHAR));
991 pszLatest[cchLatest] = L'\0';
992 }
993
994Cleanup:
995 RegSetValueExW(hkey, L"MRUList", 0, REG_SZ, (LPBYTE)pszList, (wcslen(pszList) + 1) * sizeof(WCHAR));
996
997 HeapFree(GetProcessHeap(), 0, pszCmd);
998 HeapFree(GetProcessHeap(), 0, pszList);
999
1000 RegCloseKey(hkey);
1001}
1002
1003
1004/*************************************************************************
1005 * ConfirmDialog [internal]
1006 *
1007 * Put up a confirm box, return TRUE if the user confirmed
1008 */
1009static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
1010{
1011 WCHAR Prompt[256];
1012 WCHAR Title[256];
1013
1014 LoadStringW(shell32_hInstance, PromptId, Prompt, _countof(Prompt));
1016 return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO | MB_ICONQUESTION) == IDYES;
1017}
1018
1020
1021BOOL
1023{
1025 static BOOL Initialized = FALSE;
1026 if (!Initialized)
1027 {
1028 HMODULE mod = LoadLibraryW(L"msgina.dll");
1030 Initialized = TRUE;
1031 }
1032
1033 HRESULT hr = E_FAIL;
1034 if (ShellDimScreen)
1035 hr = ShellDimScreen(pUnknown, hWindow);
1036 return SUCCEEDED(hr);
1037}
1038
1039
1040/* Used to get the shutdown privilege */
1041static BOOL
1042EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
1043{
1044 BOOL Success;
1045 HANDLE hToken;
1047
1050 &hToken);
1051 if (!Success) return Success;
1052
1054 lpszPrivilegeName,
1055 &tp.Privileges[0].Luid);
1056 if (!Success) goto Quit;
1057
1058 tp.PrivilegeCount = 1;
1059 tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
1060
1061 Success = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
1062
1063Quit:
1064 CloseHandle(hToken);
1065 return Success;
1066}
1067
1068/*************************************************************************
1069 * RestartDialogEx [SHELL32.730]
1070 */
1071
1072int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
1073{
1074 TRACE("(%p)\n", hWndOwner);
1075
1076 CComPtr<IUnknown> fadeHandler;
1077 HWND parent;
1078
1079 if (!CallShellDimScreen(&fadeHandler, &parent))
1080 parent = hWndOwner;
1081
1082 /* FIXME: use lpwstrReason */
1084 {
1085 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1086 ExitWindowsEx(EWX_REBOOT, uReason);
1087 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1088 }
1089
1090 return 0;
1091}
1092
1093/* Functions and macros used for fancy log off dialog box */
1094#define IS_PRODUCT_VERSION_WORKSTATION 0x300
1095#define FRIENDLY_LOGOFF_IS_NOT_ENFORCED 0x0
1096
1097#define FONT_POINT_SIZE 13
1098
1099#define DARK_GREY_COLOR RGB(244, 244, 244)
1100#define LIGHT_GREY_COLOR RGB(38, 38, 38)
1101
1102/* Bitmap's size for buttons */
1103#define CX_BITMAP 33
1104#define CY_BITMAP 33
1105
1106#define NUMBER_OF_BUTTONS 2
1107
1108/* After determining the button as well as its state paint the image strip bitmap using these predefined positions */
1109#define BUTTON_SWITCH_USER 0
1110#define BUTTON_SWITCH_USER_PRESSED (CY_BITMAP + BUTTON_SWITCH_USER)
1111#define BUTTON_SWITCH_USER_FOCUSED (CY_BITMAP + BUTTON_SWITCH_USER_PRESSED)
1112#define BUTTON_LOG_OFF (CY_BITMAP + BUTTON_SWITCH_USER_FOCUSED)
1113#define BUTTON_LOG_OFF_PRESSED (CY_BITMAP + BUTTON_LOG_OFF)
1114#define BUTTON_LOG_OFF_FOCUSED (CY_BITMAP + BUTTON_LOG_OFF_PRESSED)
1115#define BUTTON_SWITCH_USER_DISABLED (CY_BITMAP + BUTTON_LOG_OFF_FOCUSED) // Temporary
1116
1117/* For bIsButtonHot */
1118#define LOG_OFF_BUTTON_HOT 0
1119#define SWITCH_USER_BUTTON_HOT 1
1120
1122{
1123 BOOL bRet = FALSE;
1124 HDC hdcMem = NULL;
1125 HBITMAP hbmOld = NULL;
1126 int y = 0;
1127 RECT rect;
1128
1129 hdcMem = CreateCompatibleDC(pdis->hDC);
1130 hbmOld = (HBITMAP)SelectObject(hdcMem, pContext->hImageStrip);
1131 rect = pdis->rcItem;
1132
1133 /* Check the button ID for relevant bitmap to be used */
1134 switch (pdis->CtlID)
1135 {
1136 case IDC_LOG_OFF_BUTTON:
1137 {
1138 switch (pdis->itemAction)
1139 {
1140 case ODA_DRAWENTIRE:
1141 case ODA_FOCUS:
1142 case ODA_SELECT:
1143 {
1144 y = BUTTON_LOG_OFF;
1145 if (pdis->itemState & ODS_SELECTED)
1146 {
1148 }
1149 else if (pContext->bIsButtonHot[LOG_OFF_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
1150 {
1152 }
1153 break;
1154 }
1155 }
1156 break;
1157 }
1158
1160 {
1161 switch (pdis->itemAction)
1162 {
1163 case ODA_DRAWENTIRE:
1164 case ODA_FOCUS:
1165 case ODA_SELECT:
1166 {
1168 if (pdis->itemState & ODS_SELECTED)
1169 {
1171 }
1172 else if (pContext->bIsButtonHot[SWITCH_USER_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
1173 {
1175 }
1176
1177 /*
1178 * Since switch user functionality isn't implemented yet therefore the button has been disabled
1179 * temporarily hence show the disabled state
1180 */
1181 else if (pdis->itemState & ODS_DISABLED)
1182 {
1184 }
1185 break;
1186 }
1187 }
1188 break;
1189 }
1190 }
1191
1192 /* Draw it on the required button */
1193 bRet = BitBlt(pdis->hDC,
1194 (rect.right - rect.left - CX_BITMAP) / 2,
1195 (rect.bottom - rect.top - CY_BITMAP) / 2,
1197
1198 SelectObject(hdcMem, hbmOld);
1200
1201 return bRet;
1202}
1203
1205{
1206 PLOGOFF_DLG_CONTEXT pContext;
1208
1209 int buttonID = GetDlgCtrlID(hButton);
1210
1211 switch (uMsg)
1212 {
1213 case WM_MOUSEMOVE:
1214 {
1215 HWND hwndTarget = NULL;
1217
1218 if (GetCapture() != hButton)
1219 {
1220 SetCapture(hButton);
1221
1222 switch (buttonID)
1223 {
1224 case IDC_LOG_OFF_BUTTON:
1225 {
1227 break;
1228 }
1230 {
1232 break;
1233 }
1234 }
1236 }
1237
1238 ClientToScreen(hButton, &pt);
1239 hwndTarget = WindowFromPoint(pt);
1240
1241 if (hwndTarget != hButton)
1242 {
1244
1245 switch (buttonID)
1246 {
1247 case IDC_LOG_OFF_BUTTON:
1248 {
1250 break;
1251 }
1253 {
1255 break;
1256 }
1257 }
1258 }
1259 InvalidateRect(hButton, NULL, FALSE);
1260 break;
1261 }
1262
1263 /* Whenever one of the buttons gets the keyboard focus, set it as default button */
1264 case WM_SETFOCUS:
1265 {
1266 SendMessageW(GetParent(hButton), DM_SETDEFID, buttonID, 0);
1267 break;
1268 }
1269
1270 /* Otherwise, set IDCANCEL as default button */
1271 case WM_KILLFOCUS:
1272 {
1274 break;
1275 }
1276 }
1277 return CallWindowProcW(pContext->OldButtonProc, hButton, uMsg, wParam, lParam);
1278}
1279
1280VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID)
1281{
1282 HWND hwndTool = NULL, hwndTip = NULL;
1283 WCHAR szBuffer[256];
1284 TTTOOLINFOW tool;
1285
1286 hwndTool = GetDlgItem(hDlg, controlID);
1287
1288 tool.cbSize = sizeof(tool);
1289 tool.hwnd = hDlg;
1291 tool.uId = (UINT_PTR)hwndTool;
1292
1293 /* Create the tooltip */
1294 hwndTip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL,
1298 hDlg, NULL, shell32_hInstance, NULL);
1299
1300 /* Associate the tooltip with the tool. */
1301 LoadStringW(shell32_hInstance, detailID, szBuffer, _countof(szBuffer));
1302 tool.lpszText = szBuffer;
1303 SendMessageW(hwndTip, TTM_ADDTOOLW, 0, (LPARAM)&tool);
1304 LoadStringW(shell32_hInstance, titleID, szBuffer, _countof(szBuffer));
1305 SendMessageW(hwndTip, TTM_SETTITLEW, TTI_NONE, (LPARAM)szBuffer);
1306 SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH, 0, 250);
1307}
1308
1310{
1311 DeleteObject(pContext->hBrush);
1312 DeleteObject(pContext->hImageStrip);
1313 DeleteObject(pContext->hfFont);
1314
1315 /* Remove the subclass from the buttons */
1316 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1317 {
1320 (LONG_PTR)pContext->OldButtonProc);
1321 }
1322}
1323
1325{
1326 DWORD dwType = 0, dwValue = 0, dwSize = 0;
1327 HKEY hKey = NULL;
1328 LONG lRet = 0;
1329
1331 L"SYSTEM\\CurrentControlSet\\Control\\Windows",
1332 0,
1334 &hKey);
1335 if (lRet != ERROR_SUCCESS)
1336 return FALSE;
1337
1338 /* First check an optional ReactOS specific override, that Windows does not check.
1339 We use this to allow users pairing 'Server'-configuration with FriendlyLogoff.
1340 Otherwise users would have to change CSDVersion or LogonType (side-effects AppCompat) */
1341 dwValue = 0;
1342 dwSize = sizeof(dwValue);
1343 lRet = RegQueryValueExW(hKey,
1344 L"EnforceFriendlyLogoff",
1345 NULL,
1346 &dwType,
1347 (LPBYTE)&dwValue,
1348 &dwSize);
1349
1350 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD && dwValue != FRIENDLY_LOGOFF_IS_NOT_ENFORCED)
1351 {
1353 return TRUE;
1354 }
1355
1356 /* Check product version number */
1357 dwValue = 0;
1358 dwSize = sizeof(dwValue);
1359 lRet = RegQueryValueExW(hKey,
1360 L"CSDVersion",
1361 NULL,
1362 &dwType,
1363 (LPBYTE)&dwValue,
1364 &dwSize);
1366
1367 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD || dwValue != IS_PRODUCT_VERSION_WORKSTATION)
1368 {
1369 /* Allow Friendly UI only on Workstation */
1370 return FALSE;
1371 }
1372
1373 /* Check LogonType value */
1375 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
1376 0,
1378 &hKey);
1379 if (lRet != ERROR_SUCCESS)
1380 return FALSE;
1381
1382 dwValue = 0;
1383 dwSize = sizeof(dwValue);
1384 lRet = RegQueryValueExW(hKey,
1385 L"LogonType",
1386 NULL,
1387 &dwType,
1388 (LPBYTE)&dwValue,
1389 &dwSize);
1391
1392 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
1393 return FALSE;
1394
1395 return (dwValue != 0);
1396}
1397
1399{
1400 HDC hdc = NULL;
1401 LONG lfHeight = NULL;
1402
1403 hdc = GetDC(NULL);
1405 ReleaseDC(NULL, hdc);
1406 pContext->hfFont = CreateFontW(lfHeight, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, L"MS Shell Dlg");
1408
1410
1412
1413 /* Gather old button func */
1415
1416 /* Set bIsButtonHot to false, create tooltips for each buttons and subclass the buttons */
1417 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1418 {
1419 pContext->bIsButtonHot[i] = FALSE;
1425 hwnd,
1427 }
1428}
1429
1430/*************************************************************************
1431 * LogOffDialogProc
1432 *
1433 * NOTES: Used to make the Log Off dialog work
1434 */
1436{
1438 PLOGOFF_DLG_CONTEXT pContext;
1440
1441 switch (uMsg)
1442 {
1443 case WM_INITDIALOG:
1444 {
1445 pContext = (PLOGOFF_DLG_CONTEXT)lParam;
1447
1448 if (pContext->bFriendlyUI)
1449 FancyLogoffOnInit(hwnd, pContext);
1450 return TRUE;
1451 }
1452
1453 case WM_DESTROY:
1454 if (pContext->bFriendlyUI)
1455 EndFriendlyDialog(hwnd, pContext);
1456 return TRUE;
1457
1458 case WM_ACTIVATE:
1459 {
1460 /*
1461 * If the user deactivates the log-off dialog (it loses its focus
1462 * while the dialog is not being closed), then destroy the dialog
1463 * and cancel user logoff.
1464 */
1465 if (LOWORD(wParam) == WA_INACTIVE)
1466 {
1467 if (!pContext->bCloseDlg)
1468 {
1469 pContext->bCloseDlg = TRUE;
1471 }
1472 }
1473 return FALSE;
1474 }
1475
1476 case WM_CLOSE:
1477 pContext->bCloseDlg = TRUE;
1479 break;
1480
1481 case WM_COMMAND:
1482 switch (LOWORD(wParam))
1483 {
1484 case IDC_LOG_OFF_BUTTON:
1485 case IDOK:
1487 break;
1488
1489 case IDCANCEL:
1490 pContext->bCloseDlg = TRUE;
1492 break;
1493 }
1494 break;
1495
1496 case WM_CTLCOLORSTATIC:
1497 {
1498 /* Either make background transparent or fill it with color for required static controls */
1499 HDC hdcStatic = (HDC)wParam;
1501
1502 switch (StaticID)
1503 {
1505 SetTextColor(hdcStatic, DARK_GREY_COLOR);
1506 SetBkMode(hdcStatic, TRANSPARENT);
1508
1509 case IDC_LOG_OFF_STATIC:
1511 SetTextColor(hdcStatic, LIGHT_GREY_COLOR);
1512 SetBkMode(hdcStatic, TRANSPARENT);
1513 return (LONG_PTR)pContext->hBrush;
1514 }
1515 return FALSE;
1516 }
1517 break;
1518
1519 case WM_DRAWITEM:
1520 {
1521 /* Draw bitmaps on required buttons */
1522 switch (pdis->CtlID)
1523 {
1524 case IDC_LOG_OFF_BUTTON:
1526 return DrawIconOnOwnerDrawnButtons(pdis, pContext);
1527 }
1528 }
1529 break;
1530
1531 default:
1532 break;
1533 }
1534 return FALSE;
1535}
1536
1537/*************************************************************************
1538 * LogoffWindowsDialog [SHELL32.54]
1539 */
1540
1542{
1543 CComPtr<IUnknown> fadeHandler;
1544 HWND parent = NULL;
1545 DWORD LogoffDialogID = IDD_LOG_OFF;
1547
1548 if (!CallShellDimScreen(&fadeHandler, &parent))
1549 parent = hWndOwner;
1550
1551 Context.bFriendlyUI = IsFriendlyUIActive();
1552 if (Context.bFriendlyUI)
1553 {
1554 LogoffDialogID = IDD_LOG_OFF_FANCY;
1555 }
1556
1558 MAKEINTRESOURCEW(LogoffDialogID),
1559 parent,
1561 (LPARAM)&Context);
1562 return 0;
1563}
1564
1565/*************************************************************************
1566 * RestartDialog [SHELL32.59]
1567 */
1568
1569int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags)
1570{
1571 return RestartDialogEx(hWndOwner, lpstrReason, uFlags, 0);
1572}
1573
1574/*************************************************************************
1575 * ExitWindowsDialog_backup
1576 *
1577 * NOTES
1578 * Used as a backup solution to shutdown the OS in case msgina.dll
1579 * somehow cannot be found.
1580 */
1582{
1583 TRACE("(%p)\n", hWndOwner);
1584
1586 {
1587 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1589 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1590 }
1591}
1592
1593/*************************************************************************
1594 * ExitWindowsDialog [SHELL32.60]
1595 *
1596 * NOTES
1597 * exported by ordinal
1598 */
1599/*
1600 * TODO:
1601 * - Implement the ability to show either the Welcome Screen or the classic dialog boxes based upon the
1602 * registry value: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LogonType.
1603 */
1605{
1606 typedef DWORD (WINAPI *ShellShFunc)(HWND hWndParent, LPCWSTR pUserName, DWORD dwExcludeOptions);
1607 HINSTANCE msginaDll = LoadLibraryW(L"msgina.dll");
1608
1609 TRACE("(%p)\n", hWndOwner);
1610
1611 CComPtr<IUnknown> fadeHandler;
1612 HWND parent;
1613 if (!CallShellDimScreen(&fadeHandler, &parent))
1614 parent = hWndOwner;
1615
1616 /* If the DLL cannot be found for any reason, then it simply uses a
1617 dialog box to ask if the user wants to shut down the computer. */
1618 if (!msginaDll)
1619 {
1620 TRACE("Unable to load msgina.dll.\n");
1622 return;
1623 }
1624
1625 ShellShFunc pShellShutdownDialog = (ShellShFunc)GetProcAddress(msginaDll, "ShellShutdownDialog");
1626 if (pShellShutdownDialog)
1627 {
1628 /* Actually call the function */
1629 DWORD returnValue = pShellShutdownDialog(parent, NULL, 0);
1630
1631 switch (returnValue)
1632 {
1633 case 0x01: /* Log off user */
1634 {
1636 break;
1637 }
1638 case 0x02: /* Shut down */
1639 {
1640 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1642 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1643 break;
1644 }
1645 case 0x03: /* Install Updates/Shutdown (?) */
1646 {
1647 break;
1648 }
1649 case 0x04: /* Reboot */
1650 {
1651 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1653 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1654 break;
1655 }
1656 case 0x10: /* Sleep */
1657 {
1658 if (IsPwrSuspendAllowed())
1659 {
1660 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1662 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1663 }
1664 break;
1665 }
1666 case 0x40: /* Hibernate */
1667 {
1669 {
1670 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1672 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1673 }
1674 break;
1675 }
1676 /* If the option is any other value */
1677 default:
1678 break;
1679 }
1680 }
1681 else
1682 {
1683 /* If the function cannot be found, then revert to using the backup solution */
1684 TRACE("Unable to find the 'ShellShutdownDialog' function");
1686 }
1687
1688 FreeLibrary(msginaDll);
1689}
static LPWSTR pUserName
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
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:4265
#define IS_INTRESOURCE(x)
Definition: loader.c:613
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
BOOL WINAPI StrTrimW(WCHAR *str, const WCHAR *trim)
Definition: string.c:796
#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:1541
#define BUTTON_SWITCH_USER_DISABLED
Definition: dialogs.cpp:1115
VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID)
Definition: dialogs.cpp:1280
#define DARK_GREY_COLOR
Definition: dialogs.cpp:1099
BOOL CALLBACK EnumPickIconResourceProc(HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam)
Definition: dialogs.cpp:69
static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline)
Definition: dialogs.cpp:423
BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1121
static void FillList(HWND, LPWSTR, UINT, BOOL)
Definition: dialogs.cpp:778
int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
Definition: dialogs.cpp:1072
static void DestroyIconList(HWND hDlgCtrl, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:88
INT_PTR CALLBACK PickIconProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:186
static BOOL IsFriendlyUIActive(VOID)
Definition: dialogs.cpp:1324
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
Definition: dialogs.cpp:1042
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:352
#define CX_BITMAP
Definition: dialogs.cpp:1103
void WINAPI ExitWindowsDialog(HWND hWndOwner)
Definition: dialogs.cpp:1604
#define LOG_OFF_BUTTON_HOT
Definition: dialogs.cpp:1118
#define CX_ITEM
Definition: dialogs.cpp:183
VOID ExitWindowsDialog_backup(HWND hWndOwner)
Definition: dialogs.cpp:1581
#define BUTTON_SWITCH_USER
Definition: dialogs.cpp:1109
#define BUTTON_LOG_OFF_FOCUSED
Definition: dialogs.cpp:1114
static BOOL DoLoadIcons(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext, LPCWSTR pszFile)
Definition: dialogs.cpp:105
BOOL(WINAPI * LPFNOFN)(OPENFILENAMEW *)
Definition: dialogs.cpp:47
struct LOGOFF_DLG_CONTEXT * PLOGOFF_DLG_CONTEXT
VOID EndFriendlyDialog(HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1309
#define BUTTON_LOG_OFF
Definition: dialogs.cpp:1112
INT_PTR CALLBACK OwnerDrawButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1204
#define IS_PRODUCT_VERSION_WORKSTATION
Definition: dialogs.cpp:1094
BOOL CallShellDimScreen(IUnknown **pUnknown, HWND *hWindow)
Definition: dialogs.cpp:1022
#define NUMBER_OF_BUTTONS
Definition: dialogs.cpp:1106
static void EnableOkButtonFromEditContents(HWND hwnd)
Definition: dialogs.cpp:479
#define FONT_POINT_SIZE
Definition: dialogs.cpp:1097
static void NoIconsInFile(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:167
#define CY_BITMAP
Definition: dialogs.cpp:1104
INT_PTR CALLBACK LogOffDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1435
struct PICK_ICON_CONTEXT * PPICK_ICON_CONTEXT
#define CY_ITEM
Definition: dialogs.cpp:184
static VOID FancyLogoffOnInit(HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1398
#define CX_ICON
Definition: dialogs.cpp:179
#define SWITCH_USER_BUTTON_HOT
Definition: dialogs.cpp:1119
static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
Definition: dialogs.cpp:1009
#define LIGHT_GREY_COLOR
Definition: dialogs.cpp:1100
#define BUTTON_SWITCH_USER_PRESSED
Definition: dialogs.cpp:1110
#define BUTTON_LOG_OFF_PRESSED
Definition: dialogs.cpp:1113
#define FRIENDLY_LOGOFF_IS_NOT_ENFORCED
Definition: dialogs.cpp:1095
HRESULT(WINAPI * tShellDimScreen)(IUnknown **Unknown, HWND *hWindow)
Definition: dialogs.cpp:1019
#define BUTTON_SWITCH_USER_FOCUSED
Definition: dialogs.cpp:1111
static INT_PTR CALLBACK RunDlgProc(HWND, UINT, WPARAM, LPARAM)
Definition: dialogs.cpp:502
#define CY_ICON
Definition: dialogs.cpp:180
void WINAPI RunFileDlg(HWND hWndOwner, HICON hIcon, LPCWSTR lpstrDirectory, LPCWSTR lpstrTitle, LPCWSTR lpstrDescription, UINT uFlags)
Definition: dialogs.cpp:400
int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags)
Definition: dialogs.cpp:1569
#define ShellMessageBoxW
Definition: precomp.h:63
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
#define L(x)
Definition: resources.c:13
_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 ZeroMemory
Definition: minwinbase.h:31
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
#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
HMODULE hModule
Definition: netsh.c:17
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define BOOL
Definition: nt_native.h:43
#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
@ 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:675
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
Definition: powrprof.c:1017
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:713
#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 SHACF_FILESYSTEM
Definition: shlwapi.h:46
#define SHACF_DEFAULT
Definition: shlwapi.h:45
#define SHACF_FILESYS_ONLY
Definition: shlwapi.h:51
#define SHACF_URLALL
Definition: shlwapi.h:49
#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:615
_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:2723
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
Definition: autocomp.cpp:191
#define IDS_SHUTDOWN_TITLE
Definition: shresdef.h:82
#define IDI_SHELL_RUN
Definition: shresdef.h:618
#define IDS_LOG_OFF_TITLE
Definition: shresdef.h:389
#define IDS_NO_ICONS
Definition: shresdef.h:372
#define IDS_RESTART_TITLE
Definition: shresdef.h:80
#define IDD_PICK_ICON
Definition: shresdef.h:429
#define IDC_RUNDLG_LABEL
Definition: shresdef.h:400
#define IDC_LOG_OFF_BUTTON
Definition: shresdef.h:552
#define IDS_SHUTDOWN_PROMPT
Definition: shresdef.h:83
#define IDS_FILE_NOT_FOUND
Definition: shresdef.h:373
#define IDS_RUNDLG_BROWSE_FILTER
Definition: shresdef.h:198
#define IDC_LOG_OFF_TEXT_STATIC
Definition: shresdef.h:556
#define IDD_RUN
Definition: shresdef.h:395
#define IDC_EDIT_PATH
Definition: shresdef.h:432
#define IDC_LOG_OFF_STATIC
Definition: shresdef.h:554
#define IDC_PICKICON_LIST
Definition: shresdef.h:430
#define IDC_RUNDLG_EDITPATH
Definition: shresdef.h:399
#define IDC_RUNDLG_ICON
Definition: shresdef.h:398
#define IDS_RUNDLG_BROWSE_CAPTION
Definition: shresdef.h:197
#define IDD_LOG_OFF
Definition: shresdef.h:585
#define IDS_LOG_OFF_DESC
Definition: shresdef.h:387
#define IDC_BUTTON_PATH
Definition: shresdef.h:431
#define IDS_PICK_ICON_TITLE
Definition: shresdef.h:433
#define IDC_SWITCH_USER_BUTTON
Definition: shresdef.h:553
#define IDS_RUNDLG_BROWSE_ERROR
Definition: shresdef.h:196
#define IDC_RUNDLG_DESCRIPTION
Definition: shresdef.h:396
#define IDS_PICK_ICON_FILTER
Definition: shresdef.h:434
#define IDC_SWITCH_USER_STATIC
Definition: shresdef.h:555
#define IDD_LOG_OFF_FANCY
Definition: shresdef.h:591
#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:44
BOOL bIsButtonHot[2]
Definition: dialogs.cpp:39
HBITMAP hImageStrip
Definition: dialogs.cpp:40
HMODULE hLibrary
Definition: dialogs.cpp:61
WCHAR szPath[MAX_PATH]
Definition: dialogs.cpp:63
HICON * phIcons
Definition: dialogs.cpp:66
LPCWSTR lpstrDirectory
Definition: dialogs.cpp:29
LPCWSTR lpstrTitle
Definition: dialogs.cpp:30
LPCWSTR lpstrDescription
Definition: dialogs.cpp:31
LPCWSTR lpFile
Definition: undocshell.h:192
LPCWSTR lpDirectory
Definition: undocshell.h:193
HMODULE hLibrary
Definition: dialog.c:549
LPCWSTR lpDirectory
Definition: shellapi.h:340
Definition: tftpd.h:60
UINT_PTR idFrom
Definition: winuser.h:3260
UINT code
Definition: winuser.h:3261
HWND hwndFrom
Definition: winuser.h:3259
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
Definition: windef.h:99
LONG top
Definition: windef.h:101
LONG left
Definition: windef.h:100
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:202
#define RFN_VALIDATE
Definition: undocshell.h:179
#define RF_RETRY
Definition: undocshell.h:204
#define RF_CANCEL
Definition: undocshell.h:203
#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
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#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
#define strlenW(s)
Definition: unicode.h:34
#define strcatW(d, s)
Definition: unicode.h:36
#define isspaceW(n)
Definition: unicode.h:58
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:2583
#define LB_ERR
Definition: winuser.h:2468
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
HWND WINAPI SetCapture(_In_ HWND hWnd)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define MAKEWPARAM(l, h)
Definition: winuser.h:4111
#define EWX_SHUTDOWN
Definition: winuser.h:647
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1800
#define LB_GETCOUNT
Definition: winuser.h:2067
#define ODS_SELECTED
Definition: winuser.h:2581
#define SW_HIDE
Definition: winuser.h:779
#define LB_FINDSTRINGEXACT
Definition: winuser.h:2064
#define WM_CLOSE
Definition: winuser.h:1649
#define DM_SETDEFID
Definition: winuser.h:2135
#define DWLP_USER
Definition: winuser.h:883
#define GetWindowLongPtrW
Definition: winuser.h:4931
#define MAKELPARAM(l, h)
Definition: winuser.h:4110
#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:2578
#define STM_SETICON
Definition: winuser.h:2128
#define IDCANCEL
Definition: winuser.h:842
#define LB_SETTOPINDEX
Definition: winuser.h:2106
#define LBN_DBLCLK
Definition: winuser.h:2107
#define GWL_ID
Definition: winuser.h:870
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
#define WM_COMMAND
Definition: winuser.h:1768
#define ODA_FOCUS
Definition: winuser.h:2580
#define EWX_LOGOFF
Definition: winuser.h:644
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_SETFOCUS
Definition: winuser.h:1641
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_MOUSEMOVE
Definition: winuser.h:1803
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define WA_INACTIVE
Definition: winuser.h:2664
#define CB_RESETCONTENT
Definition: winuser.h:1988
#define WM_INITDIALOG
Definition: winuser.h:1767
#define MB_YESNO
Definition: winuser.h:828
#define LB_ADDSTRING
Definition: winuser.h:2060
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2457
#define LB_SETCOLUMNWIDTH
Definition: winuser.h:2097
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:1673
#define CBN_SELCHANGE
Definition: winuser.h:2008
#define WM_ACTIVATE
Definition: winuser.h:1640
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:2091
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI GetComboBoxInfo(_In_ HWND, _Inout_ PCOMBOBOXINFO)
#define WM_SETFONT
Definition: winuser.h:1678
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:2380
#define CB_ADDSTRING
Definition: winuser.h:1965
#define SendMessage
Definition: winuser.h:5954
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:1674
#define CB_SETEDITSEL
Definition: winuser.h:1992
#define MB_ICONWARNING
Definition: winuser.h:797
#define PostMessage
Definition: winuser.h:5943
#define CW_USEDEFAULT
Definition: winuser.h:225
HWND WINAPI GetParent(_In_ HWND)
#define LBN_SELCHANGE
Definition: winuser.h:2111
#define ODA_SELECT
Definition: winuser.h:2579
#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:1637
#define LB_SETCURSEL
Definition: winuser.h:2099
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define CB_INSERTSTRING
Definition: winuser.h:1986
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3008
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2515
#define IDYES
Definition: winuser.h:846
#define LB_GETCURSEL
Definition: winuser.h:2068
#define SetWindowLongPtrW
Definition: winuser.h:5457
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_KILLFOCUS
Definition: winuser.h:1642
#define ODS_FOCUS
Definition: winuser.h:2585
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2427
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CBN_EDITCHANGE
Definition: winuser.h:2004
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:2405
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:942
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
const char * LPCSTR
Definition: xmlstorage.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184