ReactOS  0.4.15-dev-1636-gf634010
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  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 
22 #include "precomp.h"
23 
24 typedef struct
25 {
34 
35 typedef BOOL (WINAPI * LPFNOFN) (OPENFILENAMEW *);
36 
39 static void FillList(HWND, LPWSTR, UINT, BOOL);
40 
41 
42 /*************************************************************************
43  * PickIconDlg [SHELL32.62]
44  *
45  */
46 
47 typedef struct
48 {
56 
58  LPCWSTR lpszType,
59  LPWSTR lpszName,
61 {
63  HWND hDlgCtrl = pIconContext->hDlgCtrl;
64 
65  if (IS_INTRESOURCE(lpszName))
66  lParam = LOWORD(lpszName);
67  else
68  lParam = -1;
69 
70  SendMessageW(hDlgCtrl, LB_ADDSTRING, 0, lParam);
71 
72  return TRUE;
73 }
74 
75 static void
76 DestroyIconList(HWND hDlgCtrl, PPICK_ICON_CONTEXT pIconContext)
77 {
78  int count;
79  int index;
80 
81  count = SendMessageW(hDlgCtrl, LB_GETCOUNT, 0, 0);
82  if (count == LB_ERR)
83  return;
84 
85  for(index = 0; index < count; index++)
86  {
87  DestroyIcon(pIconContext->phIcons[index]);
88  pIconContext->phIcons[index] = NULL;
89  }
90 }
91 
92 static BOOL
93 DoLoadIcons(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext, LPCWSTR pszFile)
94 {
95  WCHAR szExpandedPath[MAX_PATH];
96 
97  // Destroy previous icons
98  DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
99  SendMessageW(pIconContext->hDlgCtrl, LB_RESETCONTENT, 0, 0);
100  delete[] pIconContext->phIcons;
101 
102  // Store the path
103  StringCchCopyW(pIconContext->szPath, _countof(pIconContext->szPath), pszFile);
104  ExpandEnvironmentStringsW(pszFile, szExpandedPath, _countof(szExpandedPath));
105 
106  // Load the module if possible
108  if (pIconContext->hLibrary)
109  FreeLibrary(pIconContext->hLibrary);
110  pIconContext->hLibrary = hLibrary;
111 
112  if (pIconContext->hLibrary)
113  {
114  // Load the icons from the module
115  pIconContext->nIcons = ExtractIconExW(szExpandedPath, -1, NULL, NULL, 0);
116  pIconContext->phIcons = new HICON[pIconContext->nIcons];
117 
118  if (ExtractIconExW(szExpandedPath, 0, pIconContext->phIcons, NULL, pIconContext->nIcons))
119  {
121  }
122  else
123  {
124  pIconContext->nIcons = 0;
125  }
126  }
127  else
128  {
129  // .ico file
130  pIconContext->nIcons = 1;
131  pIconContext->phIcons = new HICON[1];
132 
133  if (ExtractIconExW(szExpandedPath, 0, pIconContext->phIcons, NULL, pIconContext->nIcons))
134  {
135  SendMessageW(pIconContext->hDlgCtrl, LB_ADDSTRING, 0, 0);
136  }
137  else
138  {
139  pIconContext->nIcons = 0;
140  }
141  }
142 
143  // Set the text and reset the edit control's modification flag
144  SetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath);
146 
147  if (pIconContext->nIcons == 0)
148  {
149  delete[] pIconContext->phIcons;
150  pIconContext->phIcons = NULL;
151  }
152 
153  return (pIconContext->nIcons > 0);
154 }
155 
156 static const LPCWSTR s_pszDefaultPath = L"%SystemRoot%\\system32\\shell32.dll";
157 
158 static void NoIconsInFile(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext)
159 {
160  // Show an error message
161  CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
162  strText.Format(IDS_NO_ICONS, pIconContext->szPath);
163  MessageBoxW(hwndDlg, strText, strTitle, MB_ICONWARNING);
164 
165  // Load the default icons
166  DoLoadIcons(hwndDlg, pIconContext, s_pszDefaultPath);
167 }
168 
169 // Icon size
170 #define CX_ICON GetSystemMetrics(SM_CXICON)
171 #define CY_ICON GetSystemMetrics(SM_CYICON)
172 
173 // Item size
174 #define CX_ITEM (CX_ICON + 4)
175 #define CY_ITEM (CY_ICON + 12)
176 
178  HWND hwndDlg,
179  UINT uMsg,
180  WPARAM wParam,
181  LPARAM lParam)
182 {
183  LPMEASUREITEMSTRUCT lpmis;
184  LPDRAWITEMSTRUCT lpdis;
185  HICON hIcon;
186  INT index, count;
187  WCHAR szText[MAX_PATH], szFilter[100];
188  CStringW strTitle;
190 
192 
193  switch(uMsg)
194  {
195  case WM_INITDIALOG:
196  {
197  pIconContext = (PPICK_ICON_CONTEXT)lParam;
198  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pIconContext);
199  pIconContext->hDlgCtrl = GetDlgItem(hwndDlg, IDC_PICKICON_LIST);
200 
201  SendMessageW(pIconContext->hDlgCtrl, LB_SETCOLUMNWIDTH, CX_ITEM, 0);
202 
203  // Load the icons
204  if (!DoLoadIcons(hwndDlg, pIconContext, pIconContext->szPath))
205  NoIconsInFile(hwndDlg, pIconContext);
206 
207  // Set the selection
208  count = SendMessageW(pIconContext->hDlgCtrl, LB_GETCOUNT, 0, 0);
209  if (count != LB_ERR)
210  {
211  if (pIconContext->Index < 0)
212  {
213  // A negative value will be interpreted as a negated resource ID.
214  LPARAM lParam = -pIconContext->Index;
215  pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_FINDSTRINGEXACT, -1, lParam);
216  }
217 
218  if (pIconContext->Index < 0 || count <= pIconContext->Index)
219  pIconContext->Index = 0;
220 
221  SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, pIconContext->Index, 0);
222  SendMessageW(pIconContext->hDlgCtrl, LB_SETTOPINDEX, pIconContext->Index, 0);
223  }
224  return TRUE;
225  }
226 
227  case WM_DESTROY:
228  {
229  DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
230  delete[] pIconContext->phIcons;
231 
232  if (pIconContext->hLibrary)
233  FreeLibrary(pIconContext->hLibrary);
234  break;
235  }
236 
237  case WM_COMMAND:
238  switch(LOWORD(wParam))
239  {
240  case IDOK:
241  {
242  /* Check whether the path edit control has been modified; if so load the icons instead of validating */
243  if (SendDlgItemMessage(hwndDlg, IDC_EDIT_PATH, EM_GETMODIFY, 0, 0))
244  {
245  /* Reset the edit control's modification flag and retrieve the text */
248 
249  // Load the icons
250  if (!DoLoadIcons(hwndDlg, pIconContext, szText))
251  NoIconsInFile(hwndDlg, pIconContext);
252 
253  // Set the selection
254  SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
255  break;
256  }
257 
258  /* The path edit control has not been modified, return the selection */
259  pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
260  GetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath, _countof(pIconContext->szPath));
261  EndDialog(hwndDlg, 1);
262  break;
263  }
264 
265  case IDCANCEL:
266  EndDialog(hwndDlg, 0);
267  break;
268 
269  case IDC_PICKICON_LIST:
270  switch (HIWORD(wParam))
271  {
272  case LBN_SELCHANGE:
274  break;
275 
276  case LBN_DBLCLK:
277  SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);
278  break;
279  }
280  break;
281 
282  case IDC_BUTTON_PATH:
283  {
284  // Choose the module path
285  szText[0] = 0;
286  szFilter[0] = 0;
287  ZeroMemory(&ofn, sizeof(ofn));
288  ofn.lStructSize = sizeof(ofn);
289  ofn.hwndOwner = hwndDlg;
290  ofn.lpstrFile = szText;
292  strTitle.LoadString(IDS_PICK_ICON_TITLE);
293  ofn.lpstrTitle = strTitle;
296  if (!GetOpenFileNameW(&ofn))
297  break;
298 
299  // Load the icons
300  if (!DoLoadIcons(hwndDlg, pIconContext, szText))
301  NoIconsInFile(hwndDlg, pIconContext);
302 
303  // Set the selection
304  SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
305  break;
306  }
307 
308  default:
309  break;
310  }
311  break;
312 
313  case WM_MEASUREITEM:
314  lpmis = (LPMEASUREITEMSTRUCT)lParam;
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)
324  {
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  int res;
358  WCHAR szExpandedPath[MAX_PATH];
359 
360  // Initialize the dialog
361  PICK_ICON_CONTEXT IconContext = { NULL };
362  IconContext.Index = *lpdwIconIndex;
363  StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), lpstrFile);
364  ExpandEnvironmentStringsW(lpstrFile, szExpandedPath, _countof(szExpandedPath));
365 
366  if (!szExpandedPath[0] ||
367  GetFileAttributesW(szExpandedPath) == INVALID_FILE_ATTRIBUTES)
368  {
369  if (szExpandedPath[0])
370  {
371  // No such file
372  CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
373  strText.Format(IDS_FILE_NOT_FOUND, lpstrFile);
374  MessageBoxW(hWndOwner, strText, strTitle, MB_ICONWARNING);
375  }
376 
377  // Set the default value
378  StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), s_pszDefaultPath);
379  }
380 
381  // Show the dialog
383  if (res)
384  {
385  // Store the selected icon
386  StringCchCopyW(lpstrFile, nMaxFile, IconContext.szPath);
387  *lpdwIconIndex = IconContext.Index;
388  }
389 
390  return res;
391 }
392 
393 /*************************************************************************
394  * RunFileDlg [internal]
395  *
396  * The Unicode function that is available as ordinal 61 on Windows NT/2000/XP/...
397  */
399  HWND hWndOwner,
400  HICON hIcon,
401  LPCWSTR lpstrDirectory,
402  LPCWSTR lpstrTitle,
403  LPCWSTR lpstrDescription,
404  UINT uFlags)
405 {
406  TRACE("\n");
407 
408  RUNFILEDLGPARAMS rfdp;
409  rfdp.hwndOwner = hWndOwner;
410  rfdp.hIcon = hIcon;
411  rfdp.lpstrDirectory = lpstrDirectory;
412  rfdp.lpstrTitle = lpstrTitle;
413  rfdp.lpstrDescription = lpstrDescription;
414  rfdp.uFlags = uFlags;
415 
417 }
418 
419 
420 /* find the directory that contains the file being run */
422 {
423  const WCHAR *src;
424  WCHAR *dest, *result, *result_end=NULL;
425  static const WCHAR dotexeW[] = L".exe";
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, dotexeW);
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)
563  CoUninitialize();
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  NMRUNFILEDLGW nmrfd;
577 
578  ic = GetWindowTextLengthW(htxt);
579  if (ic == 0)
580  {
582  return TRUE;
583  }
584 
585  /*
586  * Allocate a new MRU entry, we need to add two characters
587  * for the terminating "\\1" part, then the NULL character.
588  */
589  psz = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (ic + 2 + 1)*sizeof(WCHAR));
590  if (!psz)
591  {
593  return TRUE;
594  }
595 
596  GetWindowTextW(htxt, psz, ic + 1);
597  StrTrimW(psz, L" \t");
598 
599  if (wcschr(psz, L'%') != NULL)
600  {
601  cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0);
602  pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR));
603  if (!pszExpanded)
604  {
605  HeapFree(GetProcessHeap(), 0, psz);
607  return TRUE;
608  }
609  ExpandEnvironmentStringsW(psz, pszExpanded, cchExpand);
610  StrTrimW(pszExpanded, L" \t");
611  }
612  else
613  {
614  pszExpanded = psz;
615  }
616 
617  /*
618  * The precedence is the following: first the user-given
619  * current directory is used; if there is none, a current
620  * directory is computed if the RFF_CALCDIRECTORY is set,
621  * otherwise no current directory is defined.
622  */
623  LPCWSTR pszStartDir;
624  if (prfdp->lpstrDirectory)
625  pszStartDir = prfdp->lpstrDirectory;
626  else if (prfdp->uFlags & RFF_CALCDIRECTORY)
627  pszStartDir = parent = RunDlg_GetParentDir(pszExpanded);
628  else
629  pszStartDir = NULL;
630 
631  /* Hide the dialog for now on, we will show it up in case of retry */
633 
634  /*
635  * As shown by manual tests on Windows, modifying the contents
636  * of the notification structure will not modify what the
637  * Run-Dialog will use for the nShow parameter. However the
638  * lpFile and lpDirectory pointers are set to the buffers used
639  * by the Run-Dialog, as a consequence they can be modified by
640  * the notification receiver, as long as it respects the lengths
641  * of the buffers (to avoid buffer overflows).
642  */
643  nmrfd.hdr.code = RFN_VALIDATE;
644  nmrfd.hdr.hwndFrom = hwnd;
645  nmrfd.hdr.idFrom = 0;
646  nmrfd.lpFile = pszExpanded;
647  nmrfd.lpDirectory = pszStartDir;
648  nmrfd.nShow = SW_SHOWNORMAL;
649 
650  lRet = SendMessageW(prfdp->hwndOwner, WM_NOTIFY, 0, (LPARAM)&nmrfd.hdr);
651 
652  switch (lRet)
653  {
654  case RF_CANCEL:
656  break;
657 
658  case RF_OK:
659  if (SUCCEEDED(ShellExecCmdLine(hwnd, pszExpanded, pszStartDir, SW_SHOWNORMAL, NULL,
661  {
662  /* Call again GetWindowText in case the contents of the edit box has changed? */
663  GetWindowTextW(htxt, psz, ic + 1);
664  FillList(htxt, psz, ic + 2 + 1, FALSE);
665  EndDialog(hwnd, IDOK);
666  break;
667  }
668 
669  /* Fall-back */
670  case RF_RETRY:
671  default:
672  SendMessageW(htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
673  /* Show back the dialog */
675  break;
676  }
677 
679  HeapFree(GetProcessHeap(), 0, psz);
680  if (psz != pszExpanded)
681  HeapFree(GetProcessHeap(), 0, pszExpanded);
682  return TRUE;
683  }
684 
685  case IDCANCEL:
687  return TRUE;
688 
689  case IDC_RUNDLG_BROWSE:
690  {
691  HMODULE hComdlg = NULL;
692  LPFNOFN ofnProc = NULL;
693  WCHAR szFName[1024] = {0};
694  WCHAR filter[MAX_PATH], szCaption[MAX_PATH];
696 
699 
700  ZeroMemory(&ofn, sizeof(ofn));
701  ofn.lStructSize = sizeof(ofn);
702  ofn.hwndOwner = hwnd;
704  ofn.lpstrFile = szFName;
705  ofn.nMaxFile = _countof(szFName) - 1;
706  ofn.lpstrTitle = szCaption;
708  ofn.lpstrInitialDir = prfdp->lpstrDirectory;
709 
710  if (NULL == (hComdlg = LoadLibraryExW(L"comdlg32", NULL, 0)) ||
711  NULL == (ofnProc = (LPFNOFN)GetProcAddress(hComdlg, "GetOpenFileNameW")))
712  {
713  ERR("Couldn't get GetOpenFileName function entry (lib=%p, proc=%p)\n", hComdlg, ofnProc);
715  return TRUE;
716  }
717 
718  if (ofnProc(&ofn))
719  {
725  }
726 
727  FreeLibrary(hComdlg);
728 
729  return TRUE;
730  }
731  case IDC_RUNDLG_EDITPATH:
732  {
733  if (HIWORD(wParam) == CBN_EDITCHANGE)
734  {
736  }
737  return TRUE;
738  }
739  }
740  return TRUE;
741  }
742  return FALSE;
743 }
744 
745 /*
746  * This function grabs the MRU list from the registry and fills the combo-list
747  * for the "Run" dialog above. fShowDefault is ignored if pszLatest != NULL.
748  */
749 // FIXME: Part of this code should be part of some MRUList API,
750 // that is scattered amongst shell32, comctl32 (?!) and comdlg32.
751 static void FillList(HWND hCb, LPWSTR pszLatest, UINT cchStr, BOOL fShowDefault)
752 {
753  HKEY hkey;
754  WCHAR *pszList = NULL, *pszCmd = NULL, *pszTmp = NULL, cMatch = 0, cMax = 0x60;
755  WCHAR szIndex[2] = L"-";
756  UINT cchLatest;
757  DWORD dwType, icList = 0, icCmd = 0;
758  LRESULT lRet;
759  UINT Nix;
760 
761  /*
762  * Retrieve the string length of pszLatest and check whether its buffer size
763  * (cchStr in number of characters) is large enough to add the terminating "\\1"
764  * (and the NULL character).
765  */
766  if (pszLatest)
767  {
768  cchLatest = wcslen(pszLatest);
769  if (cchStr < cchLatest + 2 + 1)
770  {
771  TRACE("pszLatest buffer is not large enough (%d) to hold the MRU terminator.\n", cchStr);
772  return;
773  }
774  }
775  else
776  {
777  cchStr = 0;
778  }
779 
780  SendMessageW(hCb, CB_RESETCONTENT, 0, 0);
781 
783  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU",
785  if (lRet != ERROR_SUCCESS)
786  {
787  TRACE("Unable to open or create the RunMRU key, error %d\n", GetLastError());
788  return;
789  }
790 
791  lRet = RegQueryValueExW(hkey, L"MRUList", NULL, &dwType, NULL, &icList);
792  if (lRet == ERROR_SUCCESS && dwType == REG_SZ && icList > sizeof(WCHAR))
793  {
794  pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icList);
795  if (!pszList)
796  {
797  TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
798  goto Continue;
799  }
800  pszList[0] = L'\0';
801 
802  lRet = RegQueryValueExW(hkey, L"MRUList", NULL, NULL, (LPBYTE)pszList, &icList);
803  if (lRet != ERROR_SUCCESS)
804  {
805  TRACE("Unable to grab MRUList, error %d\n", GetLastError());
806  pszList[0] = L'\0';
807  }
808  }
809  else
810  {
811 Continue:
812  icList = sizeof(WCHAR);
813  pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icList);
814  if (!pszList)
815  {
816  TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
817  RegCloseKey(hkey);
818  return;
819  }
820  pszList[0] = L'\0';
821  }
822 
823  /* Convert the number of bytes from MRUList into number of characters (== number of indices) */
824  icList /= sizeof(WCHAR);
825 
826  for (Nix = 0; Nix < icList - 1; Nix++)
827  {
828  if (pszList[Nix] > cMax)
829  cMax = pszList[Nix];
830 
831  szIndex[0] = pszList[Nix];
832 
833  lRet = RegQueryValueExW(hkey, szIndex, NULL, &dwType, NULL, &icCmd);
834  if (lRet != ERROR_SUCCESS || dwType != REG_SZ)
835  {
836  TRACE("Unable to grab size of index, error %d\n", GetLastError());
837  continue;
838  }
839 
840  if (pszCmd)
841  {
842  pszTmp = (WCHAR*)HeapReAlloc(GetProcessHeap(), 0, pszCmd, icCmd);
843  if (!pszTmp)
844  {
845  TRACE("HeapReAlloc failed to reallocate %d bytes\n", icCmd);
846  continue;
847  }
848  pszCmd = pszTmp;
849  }
850  else
851  {
852  pszCmd = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icCmd);
853  if (!pszCmd)
854  {
855  TRACE("HeapAlloc failed to allocate %d bytes\n", icCmd);
856  continue;
857  }
858  }
859 
860  lRet = RegQueryValueExW(hkey, szIndex, NULL, NULL, (LPBYTE)pszCmd, &icCmd);
861  if (lRet != ERROR_SUCCESS)
862  {
863  TRACE("Unable to grab index, error %d\n", GetLastError());
864  continue;
865  }
866 
867  /*
868  * Generally the command string will end up with "\\1".
869  * Find the last backslash in the string and NULL-terminate.
870  * Windows does not seem to check for what comes next, so that
871  * a command of the form:
872  * c:\\my_dir\\myfile.exe
873  * will be cut just after "my_dir", whereas a command of the form:
874  * c:\\my_dir\\myfile.exe\\1
875  * will be cut just after "myfile.exe".
876  */
877  pszTmp = wcsrchr(pszCmd, L'\\');
878  if (pszTmp)
879  *pszTmp = L'\0';
880 
881  /*
882  * In the following we try to add pszLatest to the MRU list.
883  * We suppose that our caller has already correctly allocated
884  * the string with enough space for us to append a "\\1".
885  *
886  * FIXME: TODO! (At the moment we don't append it!)
887  */
888 
889  if (pszLatest)
890  {
891  if (wcsicmp(pszCmd, pszLatest) == 0)
892  {
893  SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszCmd);
894  SetWindowTextW(hCb, pszCmd);
895  SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
896 
897  cMatch = pszList[Nix];
898  memmove(&pszList[1], pszList, Nix * sizeof(WCHAR));
899  pszList[0] = cMatch;
900  continue;
901  }
902  }
903 
904  if (icList - 1 != 26 || icList - 2 != Nix || cMatch || pszLatest == NULL)
905  {
906  SendMessageW(hCb, CB_ADDSTRING, 0, (LPARAM)pszCmd);
907  if (!Nix && fShowDefault)
908  {
909  SetWindowTextW(hCb, pszCmd);
910  SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
911  }
912  }
913  else
914  {
915  SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest);
916  SetWindowTextW(hCb, pszLatest);
917  SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
918 
919  cMatch = pszList[Nix];
920  memmove(&pszList[1], pszList, Nix * sizeof(WCHAR));
921  pszList[0] = cMatch;
922  szIndex[0] = cMatch;
923 
924  wcscpy(&pszLatest[cchLatest], L"\\1");
925  RegSetValueExW(hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, (cchLatest + 2 + 1) * sizeof(WCHAR));
926  pszLatest[cchLatest] = L'\0';
927  }
928  }
929 
930  if (!cMatch && pszLatest != NULL)
931  {
932  SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest);
933  SetWindowTextW(hCb, pszLatest);
934  SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
935 
936  cMatch = ++cMax;
937 
938  if (pszList)
939  {
940  pszTmp = (WCHAR*)HeapReAlloc(GetProcessHeap(), 0, pszList, (++icList) * sizeof(WCHAR));
941  if (!pszTmp)
942  {
943  TRACE("HeapReAlloc failed to reallocate enough bytes\n");
944  goto Cleanup;
945  }
946  pszList = pszTmp;
947  }
948  else
949  {
950  pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (++icList) * sizeof(WCHAR));
951  if (!pszList)
952  {
953  TRACE("HeapAlloc failed to allocate enough bytes\n");
954  goto Cleanup;
955  }
956  }
957 
958  memmove(&pszList[1], pszList, (icList - 1) * sizeof(WCHAR));
959  pszList[0] = cMatch;
960  szIndex[0] = cMatch;
961 
962  wcscpy(&pszLatest[cchLatest], L"\\1");
963  RegSetValueExW(hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, (cchLatest + 2 + 1) * sizeof(WCHAR));
964  pszLatest[cchLatest] = L'\0';
965  }
966 
967 Cleanup:
968  RegSetValueExW(hkey, L"MRUList", 0, REG_SZ, (LPBYTE)pszList, (wcslen(pszList) + 1) * sizeof(WCHAR));
969 
970  HeapFree(GetProcessHeap(), 0, pszCmd);
971  HeapFree(GetProcessHeap(), 0, pszList);
972 
973  RegCloseKey(hkey);
974 }
975 
976 
977 /*************************************************************************
978  * ConfirmDialog [internal]
979  *
980  * Put up a confirm box, return TRUE if the user confirmed
981  */
982 static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
983 {
984  WCHAR Prompt[256];
985  WCHAR Title[256];
986 
987  LoadStringW(shell32_hInstance, PromptId, Prompt, _countof(Prompt));
989  return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO | MB_ICONQUESTION) == IDYES;
990 }
991 
993 
994 BOOL
996 {
998  static BOOL Initialized = FALSE;
999  if (!Initialized)
1000  {
1001  HMODULE mod = LoadLibraryW(L"msgina.dll");
1003  Initialized = TRUE;
1004  }
1005 
1006  HRESULT hr = E_FAIL;
1007  if (ShellDimScreen)
1008  hr = ShellDimScreen(pUnknown, hWindow);
1009  return SUCCEEDED(hr);
1010 }
1011 
1012 
1013 /* Used to get the shutdown privilege */
1014 static BOOL
1015 EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
1016 {
1017  BOOL Success;
1018  HANDLE hToken;
1020 
1023  &hToken);
1024  if (!Success) return Success;
1025 
1027  lpszPrivilegeName,
1028  &tp.Privileges[0].Luid);
1029  if (!Success) goto Quit;
1030 
1031  tp.PrivilegeCount = 1;
1032  tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
1033 
1034  Success = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
1035 
1036 Quit:
1037  CloseHandle(hToken);
1038  return Success;
1039 }
1040 
1041 /*************************************************************************
1042  * RestartDialogEx [SHELL32.730]
1043  */
1044 
1045 int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
1046 {
1047  TRACE("(%p)\n", hWndOwner);
1048 
1049  CComPtr<IUnknown> fadeHandler;
1050  HWND parent;
1051 
1052  if (!CallShellDimScreen(&fadeHandler, &parent))
1053  parent = hWndOwner;
1054 
1055  /* FIXME: use lpwstrReason */
1057  {
1058  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1059  ExitWindowsEx(EWX_REBOOT, uReason);
1060  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1061  }
1062 
1063  return 0;
1064 }
1065 
1066 /*************************************************************************
1067  * LogOffDialogProc
1068  *
1069  * NOTES: Used to make the Log Off dialog work
1070  */
1072 {
1073  switch (uMsg)
1074  {
1075  case WM_INITDIALOG:
1076  return TRUE;
1077 
1078  case WM_CLOSE:
1080  break;
1081 
1082 #if 0
1083  case WM_ACTIVATE:
1084  {
1085  if (LOWORD(wParam) == WA_INACTIVE)
1086  EndDialog(hwnd, 0);
1087  return FALSE;
1088  }
1089 #endif
1090 
1091  case WM_COMMAND:
1092  switch (LOWORD(wParam))
1093  {
1094  case IDOK:
1096  break;
1097 
1098  case IDCANCEL:
1100  break;
1101  }
1102  break;
1103 
1104  default:
1105  break;
1106  }
1107  return FALSE;
1108 }
1109 
1110 /*************************************************************************
1111  * LogoffWindowsDialog [SHELL32.54]
1112  */
1113 
1115 {
1116  CComPtr<IUnknown> fadeHandler;
1117  HWND parent;
1118 
1119  if (!CallShellDimScreen(&fadeHandler, &parent))
1120  parent = hWndOwner;
1121 
1123  return 0;
1124 }
1125 
1126 /*************************************************************************
1127  * RestartDialog [SHELL32.59]
1128  */
1129 
1130 int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags)
1131 {
1132  return RestartDialogEx(hWndOwner, lpstrReason, uFlags, 0);
1133 }
1134 
1135 /*************************************************************************
1136  * ExitWindowsDialog_backup
1137  *
1138  * NOTES
1139  * Used as a backup solution to shutdown the OS in case msgina.dll
1140  * somehow cannot be found.
1141  */
1143 {
1144  TRACE("(%p)\n", hWndOwner);
1145 
1147  {
1148  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1150  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1151  }
1152 }
1153 
1154 /*************************************************************************
1155  * ExitWindowsDialog [SHELL32.60]
1156  *
1157  * NOTES
1158  * exported by ordinal
1159  */
1160 /*
1161  * TODO:
1162  * - Implement the ability to show either the Welcome Screen or the classic dialog boxes based upon the
1163  * registry value: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LogonType.
1164  */
1166 {
1167  typedef DWORD (WINAPI *ShellShFunc)(HWND hParent, WCHAR *Username, BOOL bHideLogoff);
1168  HINSTANCE msginaDll = LoadLibraryW(L"msgina.dll");
1169 
1170  TRACE("(%p)\n", hWndOwner);
1171 
1172  CComPtr<IUnknown> fadeHandler;
1173  HWND parent;
1174  if (!CallShellDimScreen(&fadeHandler, &parent))
1175  parent = hWndOwner;
1176 
1177  /* If the DLL cannot be found for any reason, then it simply uses a
1178  dialog box to ask if the user wants to shut down the computer. */
1179  if (!msginaDll)
1180  {
1181  TRACE("Unable to load msgina.dll.\n");
1183  return;
1184  }
1185 
1186  ShellShFunc pShellShutdownDialog = (ShellShFunc)GetProcAddress(msginaDll, "ShellShutdownDialog");
1187 
1188  if (pShellShutdownDialog)
1189  {
1190  /* Actually call the function */
1191  DWORD returnValue = pShellShutdownDialog(parent, NULL, FALSE);
1192 
1193  switch (returnValue)
1194  {
1195  case 0x01: /* Log off user */
1196  {
1198  break;
1199  }
1200  case 0x02: /* Shut down */
1201  {
1202  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1204  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1205  break;
1206  }
1207  case 0x03: /* Install Updates/Shutdown (?) */
1208  {
1209  break;
1210  }
1211  case 0x04: /* Reboot */
1212  {
1213  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1215  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1216  break;
1217  }
1218  case 0x10: /* Sleep */
1219  {
1220  if (IsPwrSuspendAllowed())
1221  {
1222  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1224  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1225  }
1226  break;
1227  }
1228  case 0x40: /* Hibernate */
1229  {
1230  if (IsPwrHibernateAllowed())
1231  {
1232  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1234  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1235  }
1236  break;
1237  }
1238  /* If the option is any other value */
1239  default:
1240  break;
1241  }
1242  }
1243  else
1244  {
1245  /* If the function cannot be found, then revert to using the backup solution */
1246  TRACE("Unable to find the 'ShellShutdownDialog' function");
1248  }
1249 
1250  FreeLibrary(msginaDll);
1251 }
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
Definition: powrprof.c:681
#define SHACF_URLALL
Definition: shlwapi.h:1915
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define LB_SETCURSEL
Definition: winuser.h:2045
struct tagMEASUREITEMSTRUCT * LPMEASUREITEMSTRUCT
#define OFN_EXPLORER
Definition: commdlg.h:104
#define IDS_PICK_ICON_TITLE
Definition: shresdef.h:343
#define HRESULT
Definition: msvc.h:7
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define STM_SETICON
Definition: winuser.h:2074
#define IDC_RUNDLG_EDITPATH
Definition: shresdef.h:318
WINE_DEFAULT_DEBUG_CHANNEL(shell)
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
Definition: tftpd.h:59
#define RT_GROUP_ICON
Definition: pedump.c:375
static HICON
Definition: imagelist.c:84
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
static void FillList(HWND, LPWSTR, UINT, BOOL)
Definition: dialogs.cpp:751
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:598
#define COLOR_HIGHLIGHT
Definition: winuser.h:916
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define LB_FINDSTRINGEXACT
Definition: winuser.h:2017
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
#define LB_SETCOLUMNWIDTH
Definition: winuser.h:2043
#define IDC_RUNDLG_ICON
Definition: shresdef.h:317
HRESULT hr
Definition: shlfolder.c:183
#define IDYES
Definition: winuser.h:829
GLuint64EXT * result
Definition: glext.h:11304
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define LB_ADDSTRING
Definition: winuser.h:2013
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
HWND hwndOwner
Definition: commdlg.h:330
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
#define HKEY_CURRENT_USER
Definition: winreg.h:11
GLuint GLuint GLsizei count
Definition: gl.h:1545
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
static BOOL DoLoadIcons(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext, LPCWSTR pszFile)
Definition: dialogs.cpp:93
#define IDS_SHUTDOWN_PROMPT
Definition: shresdef.h:77
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
tShellDimScreen ShellDimScreen
#define INT
Definition: polytest.cpp:20
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
#define CALLBACK
Definition: compat.h:35
int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
Definition: dialogs.cpp:1045
GLdouble n
Definition: glext.h:7729
LONG top
Definition: windef.h:307
OPENFILENAME ofn
Definition: main.cpp:37
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LPCWSTR lpDirectory
Definition: undocshell.h:151
HWND WINAPI SetFocus(_In_opt_ HWND)
#define RF_OK
Definition: undocshell.h:160
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
UINT_PTR WPARAM
Definition: windef.h:207
HICON * phIcons
Definition: dialogs.cpp:54
#define SendDlgItemMessage
Definition: winuser.h:5817
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define GetWindowLongPtrW
Definition: winuser.h:4804
uint16_t * PWCHAR
Definition: typedefs.h:56
LONG left
Definition: windef.h:306
UINT uFlags
Definition: api.c:59
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDS_RUNDLG_BROWSE_ERROR
Definition: shresdef.h:185
int32_t INT_PTR
Definition: typedefs.h:64
#define EWX_REBOOT
Definition: winuser.h:633
#define IDS_RESTART_TITLE
Definition: shresdef.h:74
#define E_FAIL
Definition: ddrawi.h:102
#define BOOL
Definition: nt_native.h:43
#define RF_CANCEL
Definition: undocshell.h:161
#define LBN_SELCHANGE
Definition: winuser.h:2057
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define COLOR_WINDOW
Definition: winuser.h:908
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:58
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
static void EnableOkButtonFromEditContents(HWND hwnd)
Definition: dialogs.cpp:478
#define EWX_LOGOFF
Definition: winuser.h:631
static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline)
Definition: dialogs.cpp:421
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:1091
#define MB_ICONWARNING
Definition: winuser.h:780
DWORD nMaxFile
Definition: commdlg.h:337
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
UINT code
Definition: winuser.h:3134
LPCWSTR lpstrDescription
Definition: dialogs.cpp:30
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
#define IDC_PICKICON_LIST
Definition: shresdef.h:340
HMODULE hLibrary
Definition: dialogs.cpp:49
#define LB_RESETCONTENT
Definition: winuser.h:2037
#define IDC_RUNDLG_DESCRIPTION
Definition: shresdef.h:315
struct PICK_ICON_CONTEXT * PPICK_ICON_CONTEXT
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#define MB_YESNO
Definition: winuser.h:811
#define EWX_SHUTDOWN
Definition: winuser.h:634
static const WCHAR szText[]
Definition: dialog.c:139
#define LB_ERR
Definition: winuser.h:2407
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:351
static void NoIconsInFile(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:158
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:872
UINT_PTR idFrom
Definition: winuser.h:3133
if SUCCEEDED(hr)
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define IDS_RUNDLG_BROWSE_FILTER
Definition: shresdef.h:187
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4671
#define FIXME(fmt,...)
Definition: debug.h:111
BOOL CALLBACK EnumPickIconResourceProc(HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam)
Definition: dialogs.cpp:57
#define CB_ADDSTRING
Definition: winuser.h:1918
#define IDS_PICK_ICON_FILTER
Definition: shresdef.h:344
#define CB_INSERTSTRING
Definition: winuser.h:1939
#define IDC_RUNDLG_LABEL
Definition: shresdef.h:319
#define SHACF_FILESYSTEM
Definition: shlwapi.h:1912
#define LoadLibraryW(x)
Definition: compat.h:606
#define RFN_VALIDATE
Definition: undocshell.h:137
#define MB_ICONQUESTION
Definition: winuser.h:783
LONG_PTR LPARAM
Definition: windef.h:208
LPTSTR szFilter
Definition: mplay32.c:30
#define SECL_ALLOW_NONEXE
#define IDD_PICK_ICON
Definition: shresdef.h:339
#define CX_ITEM
Definition: dialogs.cpp:174
GLuint index
Definition: glext.h:6031
const char * LPCSTR
Definition: xmlstorage.h:183
#define SW_SHOW
Definition: winuser.h:769
void WINAPI RunFileDlg(HWND hWndOwner, HICON hIcon, LPCWSTR lpstrDirectory, LPCWSTR lpstrTitle, LPCWSTR lpstrDescription, UINT uFlags)
Definition: dialogs.cpp:398
#define LB_GETCOUNT
Definition: winuser.h:2020
#define CB_RESETCONTENT
Definition: winuser.h:1941
#define CY_ICON
Definition: dialogs.cpp:171
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4374
#define WM_DESTROY
Definition: winuser.h:1591
static INT_PTR CALLBACK RunDlgProc(HWND, UINT, WPARAM, LPARAM)
Definition: dialogs.cpp:501
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2930
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags)
Definition: dialogs.cpp:1130
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
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:4895
#define IDC_BUTTON_PATH
Definition: shresdef.h:341
#define ODA_DRAWENTIRE
Definition: winuser.h:2517
#define RFF_NOSEPARATEMEM
Definition: run.h:50
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:607
#define ShellExecCmdLine
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
static const WCHAR Title[]
Definition: oid.c:1259
#define GetProcessHeap()
Definition: compat.h:595
#define CBN_EDITCHANGE
Definition: winuser.h:1957
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
Definition: dialogs.cpp:982
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
#define IDS_SHUTDOWN_TITLE
Definition: shresdef.h:76
#define LB_SETTOPINDEX
Definition: winuser.h:2052
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
#define ASSERT(a)
Definition: mode.c:45
r parent
Definition: btrfs.c:2944
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
void WINAPI ExitWindowsDialog(HWND hWndOwner)
Definition: dialogs.cpp:1165
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:1997
LONG HRESULT
Definition: typedefs.h:79
_In_ WDFCOLLECTION _In_ ULONG Index
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define _countof(array)
Definition: sndvol32.h:68
#define WM_CLOSE
Definition: winuser.h:1603
LPCWSTR lpFile
Definition: undocshell.h:150
#define MAX_PATH
Definition: compat.h:34
DWORD lStructSize
Definition: commdlg.h:329
#define EM_GETMODIFY
Definition: winuser.h:1976
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define WINAPI
Definition: msvc.h:6
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WM_MEASUREITEM
Definition: winuser.h:1628
#define RFF_NODEFAULT
Definition: run.h:47
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define IDC_EDIT_PATH
Definition: shresdef.h:342
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
Definition: dialogs.cpp:1015
#define LBN_DBLCLK
Definition: winuser.h:2053
static void DestroyIconList(HWND hDlgCtrl, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:76
#define IDS_NO_ICONS
Definition: shresdef.h:297
WCHAR szPath[MAX_PATH]
Definition: dialogs.cpp:51
BOOL WINAPI EnumResourceNamesW(HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpfun, LONG_PTR lparam)
Definition: res.c:358
#define wcsicmp
Definition: compat.h:15
volatile int Continue
Definition: gdblib.c:102
#define IDD_RUN
Definition: shresdef.h:314
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define index(s, c)
Definition: various.h:29
static const WCHAR L[]
Definition: oid.c:1250
struct _PICK_ICON_CONTEXT PICK_ICON_CONTEXT
INT_PTR CALLBACK LogOffDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1071
#define DWLP_USER
Definition: winuser.h:866
#define MB_ICONERROR
Definition: winuser.h:781
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define RFF_NOLABEL
Definition: run.h:49
HMODULE hLibrary
Definition: odbccp32.c:12
#define IDS_FILE_NOT_FOUND
Definition: shresdef.h:298
#define DI_NORMAL
Definition: wingdi.h:72
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define GetCurrentProcess()
Definition: compat.h:618
#define EM_SETMODIFY
Definition: winuser.h:1995
GLenum src
Definition: glext.h:6340
#define WM_COMMAND
Definition: winuser.h:1722
#define wcsrchr
Definition: compat.h:16
static const WCHAR Cleanup[]
Definition: register.c:80
#define IDS_RESTART_PROMPT
Definition: shresdef.h:75
HWND hwndFrom
Definition: winuser.h:3132
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define CX_ICON
Definition: dialogs.cpp:170
#define ERR(fmt,...)
Definition: debug.h:110
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
HRESULT(WINAPI * tShellDimScreen)(IUnknown **Unknown, HWND *hWindow)
Definition: dialogs.cpp:992
#define RFF_CALCDIRECTORY
Definition: run.h:48
HWND hwndEdit
Definition: combotst.c:65
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define shell32_hInstance
#define WM_ACTIVATE
Definition: winuser.h:1594
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
LPSTR lpstrFile
Definition: commdlg.h:336
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
HICON hIcon
Definition: msconfig.c:44
#define CB_SETEDITSEL
Definition: winuser.h:1945
LPCWSTR szPath
Definition: env.c:35
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HeapReAlloc
Definition: compat.h:593
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define ShellMessageBoxW
Definition: precomp.h:58
LPCSTR lpstrFilter
Definition: commdlg.h:332
#define LB_GETCURSEL
Definition: winuser.h:2021
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define MB_OK
Definition: winuser.h:784
BOOL(WINAPI * LPFNOFN)(OPENFILENAMEW *)
Definition: dialogs.cpp:35
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
LPCWSTR lpstrTitle
Definition: dialogs.cpp:29
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static const LPCWSTR s_pszDefaultPath
Definition: dialogs.cpp:156
INT_PTR CALLBACK PickIconProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:177
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1869
#define WM_DRAWITEM
Definition: winuser.h:1627
LPCSTR lpstrTitle
Definition: commdlg.h:341
#define SendMessage
Definition: winuser.h:5818
HMODULE hLibrary
Definition: dialog.c:549
GLuint res
Definition: glext.h:9613
#define IDC_RUNDLG_BROWSE
Definition: resource.h:7
#define IDS_RUNDLG_BROWSE_CAPTION
Definition: shresdef.h:186
#define HIWORD(l)
Definition: typedefs.h:247
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define RFF_NOBROWSE
Definition: run.h:46
CAtlStringW CStringW
Definition: atlstr.h:130
LPCWSTR lpstrDirectory
Definition: dialogs.cpp:28
#define GetProcAddress(x, y)
Definition: compat.h:612
static char * dest
Definition: rtl.c:135
#define SHACF_FILESYS_ONLY
Definition: shlwapi.h:1917
#define SetWindowLongPtrW
Definition: winuser.h:5321
#define WA_INACTIVE
Definition: winuser.h:2597
EXTERN_C int WINAPI LogoffWindowsDialog(HWND hWndOwner)
Definition: dialogs.cpp:1114
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
VOID ExitWindowsDialog_backup(HWND hWndOwner)
Definition: dialogs.cpp:1142
#define GetWindowLongPtr
Definition: treelist.c:73
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
#define EXTERN_C
Definition: basetyps.h:12
#define IDD_LOG_OFF
Definition: shresdef.h:489
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define OFN_ENABLESIZING
Definition: commdlg.h:101
BOOL CallShellDimScreen(IUnknown **pUnknown, HWND *hWindow)
Definition: dialogs.cpp:995
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
Definition: powrprof.c:450
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:594
#define CY_ITEM
Definition: dialogs.cpp:175
#define ODA_SELECT
Definition: winuser.h:2518
static int mod
Definition: i386-dis.c:1281
#define WM_NOTIFY
Definition: richedit.h:61
#define IDI_SHELL_RUN
Definition: shresdef.h:521
BOOL WINAPI GetComboBoxInfo(_In_ HWND, _Inout_ PCOMBOBOXINFO)
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
Definition: autocomp.cpp:191
HMODULE hModule
Definition: animate.c:44
DWORD Flags
Definition: commdlg.h:342
#define REG_SZ
Definition: layer.c:22
#define RF_RETRY
Definition: undocshell.h:162