ReactOS  0.4.13-dev-79-gcd489d8
filetypes.cpp
Go to the documentation of this file.
1 /*
2  * 'File Types' tab property sheet of Folder Options
3  *
4  * Copyright 2007 Johannes Anderwald <johannes.anderwald@reactos.org>
5  * Copyright 2016-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 
25 
26 // DefaultIcon = %SystemRoot%\system32\SHELL32.dll,-210
27 // Verbs: Open / RunAs
28 // Cmd: rundll32.exe shell32.dll,Options_RunDLL 0
29 
31 
32 typedef struct FILE_TYPE_ENTRY
33 {
46 
47 static BOOL
48 DeleteExt(HWND hwndDlg, LPCWSTR pszExt)
49 {
50  if (*pszExt != L'.')
51  return FALSE;
52 
53  // open ".ext" key
54  HKEY hKey;
55  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, pszExt, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
56  return FALSE;
57 
58  // query "extfile" key name
59  WCHAR szValue[64] = { 0 };
60  DWORD cbValue = sizeof(szValue);
61  RegQueryValueExW(hKey, NULL, NULL, NULL, LPBYTE(szValue), &cbValue);
62  RegCloseKey(hKey);
63 
64  // delete "extfile" key (if any)
65  if (szValue[0])
67 
68  // delete ".ext" key
69  return SHDeleteKeyW(HKEY_CLASSES_ROOT, pszExt) == ERROR_SUCCESS;
70 }
71 
72 static inline HICON
74  INT iIndex = 0, BOOL bSmall = FALSE)
75 {
76  HICON hIcon = NULL;
77 
78  if (iIndex < 0)
79  {
80  // A negative value will be interpreted as a negated resource ID.
81  iIndex = -iIndex;
82 
83  INT cx, cy;
85  if (bSmall)
86  {
89  }
90  else
91  {
94  }
96  cx, cy, 0));
97  FreeLibrary(hDLL);
98  }
99  else
100  {
101  // A positive value is icon index.
102  if (bSmall)
103  ExtractIconExW(IconPath, iIndex, NULL, &hIcon, 1);
104  else
105  ExtractIconExW(IconPath, iIndex, &hIcon, NULL, 1);
106  }
107  return hIcon;
108 }
109 
110 static void
112 {
113  // Expand the REG_EXPAND_SZ string by environment variables
114  WCHAR szLocation[MAX_PATH + 32];
116  return;
117 
118  Entry->nIconIndex = PathParseIconLocationW(szLocation);
119  StringCbCopyW(Entry->IconPath, sizeof(Entry->IconPath), szLocation);
120  Entry->hIconLarge = DoExtractIcon(Entry, szLocation, Entry->nIconIndex, FALSE);
121  Entry->hIconSmall = DoExtractIcon(Entry, szLocation, Entry->nIconIndex, TRUE);
122 }
123 
124 static BOOL
126 {
127  Entry->hIconLarge = Entry->hIconSmall = NULL;
128 
129  if (lstrcmpiW(Entry->FileExtension, L".exe") == 0 ||
130  lstrcmpiW(Entry->FileExtension, L".scr") == 0)
131  {
132  // It's an executable
137  IMAGE_ICON, cx, cy, 0));
138  StringCbCopyW(Entry->IconPath, sizeof(Entry->IconPath), g_pszShell32);
139  Entry->nIconIndex = -IDI_SHELL_EXE;
140  }
141  else if (lstrcmpW(IconLocation, L"%1") == 0)
142  {
143  return FALSE; // self icon
144  }
145  else
146  {
148  }
149 
150  return Entry->hIconLarge && Entry->hIconSmall;
151 }
152 
153 static BOOL
155 {
156  Entry->hIconLarge = Entry->hIconSmall = NULL;
157 
158  // Open the "DefaultIcon" registry key
159  HKEY hDefIconKey;
160  LONG nResult = RegOpenKeyExW(hKey, L"DefaultIcon", 0, KEY_READ, &hDefIconKey);
161  if (nResult != ERROR_SUCCESS)
162  return FALSE;
163 
164  // Get the icon location
165  WCHAR szLocation[MAX_PATH + 32] = { 0 };
166  DWORD dwSize = sizeof(szLocation);
167  nResult = RegQueryValueExW(hDefIconKey, NULL, NULL, NULL, LPBYTE(szLocation), &dwSize);
168 
169  RegCloseKey(hDefIconKey);
170 
171  if (nResult != ERROR_SUCCESS || szLocation[0] == 0)
172  return FALSE;
173 
175 }
176 
177 static BOOL
179 {
180  SHFILEINFOW FileInfo = { 0 };
181  if (SHGetFileInfoW(ProgramPath, 0, &FileInfo, sizeof(FileInfo), SHGFI_DISPLAYNAME))
182  {
183  StringCchCopyW(pszName, cchName, FileInfo.szDisplayName);
184  return TRUE;
185  }
186 
187  return !!GetFileTitleW(ProgramPath, pszName, cchName);
188 }
189 
190 static void
192 {
194  INT cxSmall = GetSystemMetrics(SM_CXSMICON);
195  INT cySmall = GetSystemMetrics(SM_CYSMICON);
197  IMAGE_ICON, cxSmall, cySmall, 0));
198  StringCbCopyW(Entry->IconPath, sizeof(Entry->IconPath), g_pszShell32);
199  Entry->nIconIndex = -IDI_SHELL_FOLDER_OPTIONS;
200 }
201 
203 // EditTypeDlg
204 
205 #define LISTBOX_MARGIN 2
206 
207 typedef struct EDITTYPE_DIALOG
208 {
211  CSimpleMap<CStringW, CStringW> CommandLineMap;
216 
217 static void
219 {
221  INT IconIndex;
222 
224  IconIndex = pEditType->nIconIndex;
225  if (PickIconDlg(hwndDlg, szPath, _countof(szPath), &IconIndex))
226  {
227  // replace Windows directory with "%SystemRoot%" (for portability)
228  WCHAR szWinDir[MAX_PATH];
229  GetWindowsDirectoryW(szWinDir, _countof(szWinDir));
230  if (wcsstr(szPath, szWinDir) == 0)
231  {
232  CStringW str(L"%SystemRoot%");
233  str += &szPath[wcslen(szWinDir)];
234  StringCbCopyW(szPath, sizeof(szPath), LPCWSTR(str));
235  }
236 
237  // update FILE_TYPE_ENTRY
238  PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
239  DestroyIcon(pEntry->hIconLarge);
240  DestroyIcon(pEntry->hIconSmall);
241  pEntry->hIconLarge = DoExtractIcon(pEntry, szPath, IconIndex, FALSE);
242  pEntry->hIconSmall = DoExtractIcon(pEntry, szPath, IconIndex, TRUE);
243 
244  // update EDITTYPE_DIALOG
245  StringCbCopyW(pEditType->szIconPath, sizeof(pEditType->szIconPath), szPath);
246  pEditType->nIconIndex = IconIndex;
247 
248  // set icon to dialog
250  }
251 }
252 
253 static BOOL
255 {
256  WCHAR szText[64];
257  HFONT hFont, hFont2;
258 
259  if (!pDraw)
260  return FALSE;
261 
262  // fill rect and set colors
263  if (pDraw->itemState & ODS_SELECTED)
264  {
265  FillRect(pDraw->hDC, &pDraw->rcItem, HBRUSH(COLOR_HIGHLIGHT + 1));
268  }
269  else
270  {
271  FillRect(pDraw->hDC, &pDraw->rcItem, HBRUSH(COLOR_WINDOW + 1));
274  }
275 
276  // get listbox text
277  HWND hwndListBox = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
278  SendMessageW(hwndListBox, LB_GETTEXT, pDraw->itemID, (LPARAM)szText);
279 
280  // is it default?
281  hFont = (HFONT)SendMessageW(hwndListBox, WM_GETFONT, 0, 0);
282  if (lstrcmpiW(pEditType->szDefaultVerb, szText) == 0)
283  {
284  // default. set bold
285  LOGFONTW lf;
286  GetObject(hFont, sizeof(lf), &lf);
287  lf.lfWeight = FW_BOLD;
288  hFont2 = CreateFontIndirectW(&lf);
289  if (hFont2)
290  {
291  HGDIOBJ hFontOld = SelectObject(pDraw->hDC, hFont2);
293  DrawTextW(pDraw->hDC, szText, -1, &pDraw->rcItem,
296  SelectObject(pDraw->hDC, hFontOld);
297  DeleteObject(hFont2);
298  }
299  }
300  else
301  {
302  // non-default
304  DrawTextW(pDraw->hDC, szText, -1, &pDraw->rcItem,
307  }
308 
309  // draw focus rect
310  if (pDraw->itemState & ODS_FOCUS)
311  {
312  DrawFocusRect(pDraw->hDC, &pDraw->rcItem);
313  }
314  return TRUE;
315 }
316 
317 static BOOL
319 {
320  if (!pMeasure)
321  return FALSE;
322 
323  HWND hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
324 
325  HDC hDC = GetDC(hwndLB);
326  if (hDC)
327  {
328  TEXTMETRICW tm;
330  pMeasure->itemHeight = tm.tmHeight + LISTBOX_MARGIN * 2;
331  ReleaseDC(hwndLB, hDC);
332  return TRUE;
333  }
334  return FALSE;
335 }
336 
338 // NewExtDlg
339 
340 typedef struct NEWEXT_DIALOG
341 {
349 
350 static VOID
352 {
353  // If "Advanced" button was clicked, then we shrink or expand the dialog.
354  RECT rc, rc1, rc2;
355 
356  GetWindowRect(hwndDlg, &rc);
357  rc.bottom = rc.top + (pNewExt->rcDlg.bottom - pNewExt->rcDlg.top);
358 
359  GetWindowRect(GetDlgItem(hwndDlg, IDOK), &rc1);
360  MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc1, 2);
361 
362  GetWindowRect(GetDlgItem(hwndDlg, IDCANCEL), &rc2);
363  MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc2, 2);
364 
365  if (pNewExt->bAdvanced)
366  {
367  rc1.top += pNewExt->dy;
368  rc1.bottom += pNewExt->dy;
369 
370  rc2.top += pNewExt->dy;
371  rc2.bottom += pNewExt->dy;
372 
375 
377  SetDlgItemTextW(hwndDlg, IDC_NEWEXT_ADVANCED, strLeft);
378 
380  }
381  else
382  {
383  rc1.top -= pNewExt->dy;
384  rc1.bottom -= pNewExt->dy;
385 
386  rc2.top -= pNewExt->dy;
387  rc2.bottom -= pNewExt->dy;
388 
391 
393  SetDlgItemTextW(hwndDlg, IDC_NEWEXT_ADVANCED, strRight);
394 
395  rc.bottom -= pNewExt->dy;
396 
398  SetDlgItemTextW(hwndDlg, IDC_NEWEXT_COMBOBOX, strText);
399  }
400 
401  HDWP hDWP = BeginDeferWindowPos(3);
402 
403  if (hDWP)
404  hDWP = DeferWindowPos(hDWP, GetDlgItem(hwndDlg, IDOK), NULL,
405  rc1.left, rc1.top, rc1.right - rc1.left, rc1.bottom - rc1.top,
407  if (hDWP)
408  hDWP = DeferWindowPos(hDWP, GetDlgItem(hwndDlg, IDCANCEL), NULL,
409  rc2.left, rc2.top, rc2.right - rc2.left, rc2.bottom - rc2.top,
411  if (hDWP)
412  hDWP = DeferWindowPos(hDWP, hwndDlg, NULL,
413  rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
415 
416  if (hDWP)
417  EndDeferWindowPos(hDWP);
418 }
419 
420 static BOOL
422 {
423  pNewExt->bAdvanced = FALSE;
424 
425  // get window rectangle
426  GetWindowRect(hwndDlg, &pNewExt->rcDlg);
427 
428  // get delta Y
429  RECT rc1, rc2;
430  GetWindowRect(GetDlgItem(hwndDlg, IDC_NEWEXT_EDIT), &rc1);
432  pNewExt->dy = rc2.top - rc1.top;
433 
434  // initialize
439 
440  // shrink it first time
441  NewExtDlg_OnAdvanced(hwndDlg, pNewExt);
442 
443  return TRUE;
444 }
445 
446 static BOOL
448 {
450  INT iItem;
451 
452  GetDlgItemTextW(hwndDlg, IDC_NEWEXT_EDIT, pNewExt->szExt, _countof(pNewExt->szExt));
453  StrTrimW(pNewExt->szExt, g_pszSpace);
454  _wcsupr(pNewExt->szExt);
455 
456  GetDlgItemTextW(hwndDlg, IDC_NEWEXT_COMBOBOX, pNewExt->szFileType, _countof(pNewExt->szFileType));
457  StrTrimW(pNewExt->szFileType, g_pszSpace);
458 
459  if (pNewExt->szExt[0] == 0)
460  {
463  MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
464  return FALSE;
465  }
466 
467  ZeroMemory(&find, sizeof(find));
468  find.flags = LVFI_STRING;
469  if (pNewExt->szExt[0] == L'.')
470  {
471  find.psz = &pNewExt->szExt[1];
472  }
473  else
474  {
475  find.psz = pNewExt->szExt;
476  }
477 
478  iItem = ListView_FindItem(pNewExt->hwndLV, -1, &find);
479  if (iItem >= 0)
480  {
481  // already exists
482 
483  // get file type
484  WCHAR szFileType[64];
485  LV_ITEM item;
486  ZeroMemory(&item, sizeof(item));
487  item.mask = LVIF_TEXT;
488  item.pszText = szFileType;
489  item.cchTextMax = _countof(szFileType);
490  item.iItem = iItem;
491  item.iSubItem = 1;
492  ListView_GetItem(pNewExt->hwndLV, &item);
493 
494  // get text
495  CStringW strText;
496  strText.Format(IDS_NEWEXT_ALREADY_ASSOC, find.psz, szFileType, find.psz, szFileType);
497 
498  // get title
499  CStringW strTitle;
501 
502  if (MessageBoxW(hwndDlg, strText, strTitle, MB_ICONWARNING | MB_YESNO) == IDNO)
503  {
504  return FALSE;
505  }
506 
507  // Delete the extension
508  CStringW strExt(L".");
509  strExt += find.psz;
510  strExt.MakeLower();
511  DeleteExt(hwndDlg, strExt);
512 
513  // Delete the item
514  ListView_DeleteItem(pNewExt->hwndLV, iItem);
515  }
516 
517  EndDialog(hwndDlg, IDOK);
518  return TRUE;
519 }
520 
521 // IDD_NEWEXTENSION
522 static INT_PTR CALLBACK
524  HWND hwndDlg,
525  UINT uMsg,
526  WPARAM wParam,
527  LPARAM lParam)
528 {
529  static PNEWEXT_DIALOG s_pNewExt = NULL;
530 
531  switch (uMsg)
532  {
533  case WM_INITDIALOG:
534  s_pNewExt = (PNEWEXT_DIALOG)lParam;
535  NewExtDlg_OnInitDialog(hwndDlg, s_pNewExt);
536  return TRUE;
537 
538  case WM_COMMAND:
539  switch (LOWORD(wParam))
540  {
541  case IDOK:
542  NewExtDlg_OnOK(hwndDlg, s_pNewExt);
543  break;
544 
545  case IDCANCEL:
546  EndDialog(hwndDlg, IDCANCEL);
547  break;
548 
549  case IDC_NEWEXT_ADVANCED:
550  s_pNewExt->bAdvanced = !s_pNewExt->bAdvanced;
551  NewExtDlg_OnAdvanced(hwndDlg, s_pNewExt);
552  break;
553  }
554  break;
555  }
556  return 0;
557 }
558 
559 static BOOL
561 {
563  HKEY hKey;
564  LVITEMW lvItem;
565  DWORD dwSize;
566  DWORD dwType;
567 
568  if (szName[0] != L'.')
569  {
570  // FIXME handle URL protocol handlers
571  return FALSE;
572  }
573 
574  // get imagelists of listview
577 
578  // allocate file type entry
580  if (!Entry)
581  return FALSE;
582 
583  // open key
585  {
587  return FALSE;
588  }
589 
590  // FIXME check for duplicates
591 
592  // query for the default key
593  dwSize = sizeof(Entry->ClassKey);
594  if (RegQueryValueExW(hKey, NULL, NULL, NULL, LPBYTE(Entry->ClassKey), &dwSize) != ERROR_SUCCESS)
595  {
596  // no link available
597  Entry->ClassKey[0] = 0;
598  }
599 
600  Entry->ClassName[0] = 0;
601  if (Entry->ClassKey[0])
602  {
603  HKEY hTemp;
604  // try open linked key
605  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, Entry->ClassKey, 0, KEY_READ, &hTemp) == ERROR_SUCCESS)
606  {
607  DWORD dwSize = sizeof(Entry->ClassName);
608  RegQueryValueExW(hTemp, NULL, NULL, NULL, LPBYTE(Entry->ClassName), &dwSize);
609 
610  // use linked key
611  RegCloseKey(hKey);
612  hKey = hTemp;
613  }
614  }
615 
616  // read friendly type name
617  if (RegLoadMUIStringW(hKey, L"FriendlyTypeName", Entry->FileDescription,
618  sizeof(Entry->FileDescription), NULL, 0, NULL) != ERROR_SUCCESS)
619  {
620  // read file description
621  dwSize = sizeof(Entry->FileDescription);
622  Entry->FileDescription[0] = 0;
623 
624  // read default key
625  RegQueryValueExW(hKey, NULL, NULL, NULL, LPBYTE(Entry->FileDescription), &dwSize);
626  }
627 
628  // Read the EditFlags value
629  Entry->EditFlags = 0;
630  if (!RegQueryValueExW(hKey, L"EditFlags", NULL, &dwType, NULL, &dwSize))
631  {
632  if ((dwType == REG_DWORD || dwType == REG_BINARY) && dwSize == sizeof(DWORD))
633  RegQueryValueExW(hKey, L"EditFlags", NULL, NULL, (LPBYTE)&Entry->EditFlags, &dwSize);
634  }
635 
636  // convert extension to upper case
637  wcscpy(Entry->FileExtension, szName);
638  _wcsupr(Entry->FileExtension);
639 
640  // get icon
641  if (!GetFileTypeIconsByKey(hKey, Entry))
642  {
643  // set default icon
645  }
646 
647  // close key
648  RegCloseKey(hKey);
649 
650  // get program path and app name
651  DWORD cch = _countof(Entry->ProgramPath);
653  Entry->FileExtension, NULL, Entry->ProgramPath, &cch))
654  {
655  QueryFileDescription(Entry->ProgramPath, Entry->AppName, _countof(Entry->AppName));
656  }
657  else
658  {
659  Entry->ProgramPath[0] = Entry->AppName[0] = 0;
660  }
661 
662  // add icon to imagelist
663  INT iLargeImage = -1, iSmallImage = -1;
664  if (Entry->hIconLarge && Entry->hIconSmall)
665  {
666  iLargeImage = ImageList_AddIcon(himlLarge, Entry->hIconLarge);
667  iSmallImage = ImageList_AddIcon(himlSmall, Entry->hIconSmall);
668  ASSERT(iLargeImage == iSmallImage);
669  }
670 
671  // Do not add excluded entries
672  if (Entry->EditFlags & 0x00000001) //FTA_Exclude
673  {
674  DestroyIcon(Entry->hIconLarge);
675  DestroyIcon(Entry->hIconSmall);
677  return FALSE;
678  }
679 
680  if (!Entry->FileDescription[0])
681  {
682  // construct default 'FileExtensionFile' by formatting the uppercase extension
683  // with IDS_FILE_EXT_TYPE, outputting something like a l18n 'INI File'
684 
685  StringCbPrintf(Entry->FileDescription, sizeof(Entry->FileDescription), szFile, &Entry->FileExtension[1]);
686  }
687 
688  ZeroMemory(&lvItem, sizeof(LVITEMW));
689  lvItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
690  lvItem.iSubItem = 0;
691  lvItem.pszText = &Entry->FileExtension[1];
692  lvItem.iItem = iItem;
693  lvItem.lParam = (LPARAM)Entry;
694  lvItem.iImage = iSmallImage;
696 
697  ZeroMemory(&lvItem, sizeof(LVITEMW));
698  lvItem.mask = LVIF_TEXT;
699  lvItem.pszText = Entry->FileDescription;
700  lvItem.iItem = iItem;
701  lvItem.iSubItem = 1;
702  ListView_SetItem(hListView, &lvItem);
703 
704  return TRUE;
705 }
706 
707 static BOOL
708 FileTypesDlg_AddExt(HWND hwndDlg, LPCWSTR pszExt, LPCWSTR pszFileType)
709 {
710  DWORD dwValue = 1;
711  HKEY hKey;
712  WCHAR szKey[13]; // max. "ft4294967295" + "\0"
713  LONG nResult;
714 
715  // Search the next "ft%06u" key name
716  do
717  {
718  StringCbPrintfW(szKey, sizeof(szKey), L"ft%06u", dwValue);
719 
720  nResult = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hKey);
721  if (nResult != ERROR_SUCCESS)
722  break;
723 
724  RegCloseKey(hKey);
725  ++dwValue;
726  } while (dwValue != 0);
727 
728  RegCloseKey(hKey);
729 
730  if (dwValue == 0)
731  return FALSE;
732 
733  // Create new "ft%06u" key
734  nResult = RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
735  if (ERROR_SUCCESS != nResult)
736  return FALSE;
737 
738  RegCloseKey(hKey);
739 
740  // Create the ".ext" key
741  WCHAR szExt[16];
742  if (*pszExt == L'.')
743  ++pszExt;
744  StringCbPrintfW(szExt, sizeof(szExt), L".%s", pszExt);
745  _wcslwr(szExt);
746  nResult = RegCreateKeyEx(HKEY_CLASSES_ROOT, szExt, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
747  _wcsupr(szExt);
748  if (ERROR_SUCCESS != nResult)
749  return FALSE;
750 
751  // Set the default value of ".ext" to "ft%06u"
752  DWORD dwSize = (lstrlen(szKey) + 1) * sizeof(WCHAR);
753  RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)szKey, dwSize);
754 
755  RegCloseKey(hKey);
756 
757  // Make up the file type name
758  WCHAR szFile[100];
760  StringCbPrintfW(szFile, sizeof(szFile), strFormat, &szExt[1]);
761 
762  // Insert an item to the listview
765  if (!FileTypesDlg_InsertToLV(hListView, szExt, iItem, szFile))
766  return FALSE;
767 
768  LV_ITEM item;
769  ZeroMemory(&item, sizeof(item));
770  item.mask = LVIF_STATE | LVIF_TEXT;
771  item.iItem = iItem;
772  item.state = LVIS_SELECTED | LVIS_FOCUSED;
773  item.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
774  item.pszText = &szExt[1];
776 
777  item.pszText = szFile;
778  item.iSubItem = 1;
780 
782 
783  return TRUE;
784 }
785 
786 static BOOL
788 {
790 
792  if (iItem == -1)
793  return FALSE;
794 
795  WCHAR szExt[20];
796  szExt[0] = L'.';
797  ListView_GetItemText(hListView, iItem, 0, &szExt[1], _countof(szExt) - 1);
798  _wcslwr(szExt);
799 
800  DeleteExt(hwndDlg, szExt);
802  return TRUE;
803 }
804 
806 // common code of NewActionDlg and EditActionDlg
807 
808 typedef struct ACTION_DIALOG
809 {
816 
817 static void
818 ActionDlg_OnBrowse(HWND hwndDlg, PACTION_DIALOG pNewAct, BOOL bEdit = FALSE)
819 {
820  WCHAR szFile[MAX_PATH];
821  szFile[0] = 0;
822 
825 
827 
829  ZeroMemory(&ofn, sizeof(ofn));
831  ofn.hwndOwner = hwndDlg;
833  ofn.lpstrFile = szFile;
834  ofn.nMaxFile = _countof(szFile);
835  ofn.lpstrTitle = strTitle;
837  ofn.lpstrDefExt = L"exe";
838  if (GetOpenFileNameW(&ofn))
839  {
840  if (bEdit)
841  {
842  CStringW str = szFile;
843  str += L" \"%1\"";
845  }
846  else
847  {
848  SetDlgItemTextW(hwndDlg, IDC_ACTION_APP, szFile);
849  }
850  }
851 }
852 
854 // NewActionDlg
855 
856 static void
858 {
859  // check action
860  GetDlgItemTextW(hwndDlg, IDC_ACTION_ACTION, pNewAct->szAction, _countof(pNewAct->szAction));
861  StrTrimW(pNewAct->szAction, g_pszSpace);
862  if (pNewAct->szAction[0] == 0)
863  {
864  // action was empty, error
865  HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_ACTION);
866  SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
867  SetFocus(hwndCtrl);
870  MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
871  return;
872  }
873 
874  // check app
875  GetDlgItemTextW(hwndDlg, IDC_ACTION_APP, pNewAct->szApp, _countof(pNewAct->szApp));
876  StrTrimW(pNewAct->szApp, g_pszSpace);
877  if (pNewAct->szApp[0] == 0 ||
879  {
880  // app was empty or invalid
881  HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_APP);
882  SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
883  SetFocus(hwndCtrl);
886  MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
887  return;
888  }
889 
890  EndDialog(hwndDlg, IDOK);
891 }
892 
893 // IDD_ACTION
894 static INT_PTR CALLBACK
896 {
897  static PACTION_DIALOG s_pNewAct = NULL;
898 
899  switch (uMsg)
900  {
901  case WM_INITDIALOG:
902  s_pNewAct = (PACTION_DIALOG)lParam;
903  s_pNewAct->bUseDDE = FALSE;
905  return TRUE;
906 
907  case WM_COMMAND:
908  switch (LOWORD(wParam))
909  {
910  case IDOK:
911  NewActionDlg_OnOK(hwndDlg, s_pNewAct);
912  break;
913 
914  case IDCANCEL:
915  EndDialog(hwndDlg, IDCANCEL);
916  break;
917 
918  case IDC_ACTION_BROWSE:
919  ActionDlg_OnBrowse(hwndDlg, s_pNewAct, FALSE);
920  break;
921  }
922  break;
923  }
924  return 0;
925 }
926 
928 // EditActionDlg
929 
930 static void
932 {
933  // check action
934  GetDlgItemTextW(hwndDlg, IDC_ACTION_ACTION, pEditAct->szAction, _countof(pEditAct->szAction));
935  StrTrimW(pEditAct->szAction, g_pszSpace);
936  if (pEditAct->szAction[0] == 0)
937  {
938  // action was empty. show error
939  HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_ACTION);
940  SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
941  SetFocus(hwndCtrl);
944  MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
945  }
946 
947  // check app
948  GetDlgItemTextW(hwndDlg, IDC_ACTION_APP, pEditAct->szApp, _countof(pEditAct->szApp));
949  StrTrimW(pEditAct->szApp, g_pszSpace);
950  if (pEditAct->szApp[0] == 0)
951  {
952  // app was empty. show error
953  HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_APP);
954  SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
955  SetFocus(hwndCtrl);
958  MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
959  }
960 
961  EndDialog(hwndDlg, IDOK);
962 }
963 
964 // IDD_ACTION
965 static INT_PTR CALLBACK
967 {
968  static PACTION_DIALOG s_pEditAct = NULL;
969 
970  switch (uMsg)
971  {
972  case WM_INITDIALOG:
973  s_pEditAct = (PACTION_DIALOG)lParam;
974  s_pEditAct->bUseDDE = FALSE;
975  SetDlgItemTextW(hwndDlg, IDC_ACTION_ACTION, s_pEditAct->szAction);
976  SetDlgItemTextW(hwndDlg, IDC_ACTION_APP, s_pEditAct->szApp);
979  {
980  // set title
982  str += s_pEditAct->ClassName;
983  SetWindowTextW(hwndDlg, str);
984  }
985  return TRUE;
986 
987  case WM_COMMAND:
988  switch (LOWORD(wParam))
989  {
990  case IDOK:
991  EditActionDlg_OnOK(hwndDlg, s_pEditAct);
992  break;
993 
994  case IDCANCEL:
995  EndDialog(hwndDlg, IDCANCEL);
996  break;
997 
998  case IDC_ACTION_BROWSE:
999  ActionDlg_OnBrowse(hwndDlg, s_pEditAct, TRUE);
1000  break;
1001  }
1002  break;
1003  }
1004  return 0;
1005 }
1006 
1008 // EditTypeDlg
1009 
1010 static BOOL
1013 {
1014  PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1015 
1016  BOOL bIconSet = FALSE;
1017  if (IconPath && IconPath[0])
1018  {
1019  DestroyIcon(pEntry->hIconLarge);
1020  DestroyIcon(pEntry->hIconSmall);
1021  pEntry->hIconLarge = DoExtractIcon(pEntry, IconPath, IconIndex, FALSE);
1022  pEntry->hIconSmall = DoExtractIcon(pEntry, IconPath, IconIndex, TRUE);
1023 
1024  bIconSet = (pEntry->hIconLarge && pEntry->hIconSmall);
1025  }
1026  if (bIconSet)
1027  {
1028  StringCbCopyW(pEntry->IconPath, sizeof(pEntry->IconPath), IconPath);
1029  pEntry->nIconIndex = IconIndex;
1030  }
1031  else
1032  {
1034  }
1035 
1036  HWND hListView = pEditType->hwndLV;
1039 
1040  INT iLargeImage = ImageList_AddIcon(himlLarge, pEntry->hIconLarge);
1041  INT iSmallImage = ImageList_AddIcon(himlSmall, pEntry->hIconSmall);
1042  ASSERT(iLargeImage == iSmallImage);
1043 
1045  if (iItem != -1)
1046  {
1047  LV_ITEMW Item = { LVIF_IMAGE, iItem };
1048  Item.iImage = iSmallImage;
1049  ListView_SetItem(hListView, &Item);
1050  }
1051  return TRUE;
1052 }
1053 
1054 static BOOL
1056  LPCWSTR ClassKey, LPCWSTR ClassName, INT cchName)
1057 {
1058  PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1059 
1060  if (ClassKey[0] == 0)
1061  return FALSE;
1062 
1063  // create or open class key
1064  HKEY hClassKey;
1065  if (RegCreateKeyExW(HKEY_CLASSES_ROOT, ClassKey, 0, NULL, 0, KEY_WRITE, NULL,
1067  {
1068  return FALSE;
1069  }
1070 
1071  // create "DefaultIcon" key
1072  if (pEntry->IconPath[0])
1073  {
1074  HKEY hDefaultIconKey;
1075  if (RegCreateKeyExW(hClassKey, L"DefaultIcon", 0, NULL, 0, KEY_WRITE, NULL,
1076  &hDefaultIconKey, NULL) == ERROR_SUCCESS)
1077  {
1079  StringCbPrintfW(szText, sizeof(szText), L"%s,%d",
1080  pEntry->IconPath, pEntry->nIconIndex);
1081 
1082  // set icon location
1083  DWORD dwSize = (lstrlenW(szText) + 1) * sizeof(WCHAR);
1084  RegSetValueExW(hDefaultIconKey, NULL, 0, REG_EXPAND_SZ, LPBYTE(szText), dwSize);
1085 
1086  RegCloseKey(hDefaultIconKey);
1087  }
1088  }
1089 
1090  // create "shell" key
1091  HKEY hShellKey;
1092  if (RegCreateKeyExW(hClassKey, L"shell", 0, NULL, 0, KEY_WRITE, NULL,
1093  &hShellKey, NULL) != ERROR_SUCCESS)
1094  {
1096  return FALSE;
1097  }
1098 
1099  // delete shell commands
1100  WCHAR szVerbName[64];
1101  DWORD dwIndex = 0;
1102  while (RegEnumKeyW(hShellKey, dwIndex, szVerbName, _countof(szVerbName)) == ERROR_SUCCESS)
1103  {
1104  if (pEditType->CommandLineMap.FindKey(szVerbName) == -1)
1105  {
1106  // doesn't exist in CommandLineMap, then delete it
1107  if (SHDeleteKeyW(hShellKey, szVerbName) == ERROR_SUCCESS)
1108  {
1109  --dwIndex;
1110  }
1111  }
1112  ++dwIndex;
1113  }
1114 
1115  // set default action
1116  RegSetValueExW(hShellKey, NULL, 0, REG_SZ,
1117  LPBYTE(pEditType->szDefaultVerb), sizeof(pEditType->szDefaultVerb));
1118 
1119  // write shell commands
1120  const INT nCount = pEditType->CommandLineMap.GetSize();
1121  for (INT i = 0; i < nCount; ++i)
1122  {
1123  CStringW& key = pEditType->CommandLineMap.GetKeyAt(i);
1124  CStringW& value = pEditType->CommandLineMap.GetValueAt(i);
1125 
1126  // create verb key
1127  HKEY hVerbKey;
1128  if (RegCreateKeyExW(hShellKey, key, 0, NULL, 0, KEY_WRITE, NULL,
1129  &hVerbKey, NULL) == ERROR_SUCCESS)
1130  {
1131  // create command key
1132  HKEY hCommandKey;
1133  if (RegCreateKeyExW(hVerbKey, L"command", 0, NULL, 0, KEY_WRITE, NULL,
1134  &hCommandKey, NULL) == ERROR_SUCCESS)
1135  {
1136  // write the default value
1137  DWORD dwSize = (value.GetLength() + 1) * sizeof(WCHAR);
1138  RegSetValueExW(hCommandKey, NULL, 0, REG_EXPAND_SZ, LPBYTE(LPCWSTR(value)), dwSize);
1139 
1140  RegCloseKey(hCommandKey);
1141  }
1142 
1143  RegCloseKey(hVerbKey);
1144  }
1145  }
1146 
1147  // set class name to class key
1148  RegSetValueExW(hClassKey, NULL, 0, REG_SZ, LPBYTE(ClassName), cchName);
1149 
1150  RegCloseKey(hShellKey);
1152 
1153  return TRUE;
1154 }
1155 
1156 static BOOL
1158 {
1159  // open class key
1160  HKEY hClassKey;
1162  return FALSE;
1163 
1164  // open "shell" key
1165  HKEY hShellKey;
1166  if (RegOpenKeyExW(hClassKey, L"shell", 0, KEY_READ, &hShellKey) != ERROR_SUCCESS)
1167  {
1169  return FALSE;
1170  }
1171 
1172  WCHAR DefaultVerb[64];
1173  DWORD dwSize = sizeof(DefaultVerb);
1174  if (RegQueryValueExW(hShellKey, NULL, NULL, NULL,
1175  LPBYTE(DefaultVerb), &dwSize) == ERROR_SUCCESS)
1176  {
1177  StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), DefaultVerb);
1178  }
1179  else
1180  {
1181  StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), L"open");
1182  }
1183 
1184  // enumerate shell verbs
1185  WCHAR szVerbName[64];
1186  DWORD dwIndex = 0;
1187  while (RegEnumKeyW(hShellKey, dwIndex, szVerbName, _countof(szVerbName)) == ERROR_SUCCESS)
1188  {
1189  // open verb key
1190  HKEY hVerbKey;
1191  LONG nResult = RegOpenKeyExW(hShellKey, szVerbName, 0, KEY_READ, &hVerbKey);
1192  if (nResult == ERROR_SUCCESS)
1193  {
1194  // open command key
1195  HKEY hCommandKey;
1196  nResult = RegOpenKeyExW(hVerbKey, L"command", 0, KEY_READ, &hCommandKey);
1197  if (nResult == ERROR_SUCCESS)
1198  {
1199  // get command line
1200  WCHAR szValue[MAX_PATH + 32];
1201  dwSize = sizeof(szValue);
1202  nResult = RegQueryValueExW(hCommandKey, NULL, NULL, NULL, LPBYTE(szValue), &dwSize);
1203  if (nResult == ERROR_SUCCESS)
1204  {
1205  pEditType->CommandLineMap.SetAt(szVerbName, szValue);
1206  }
1207 
1208  RegCloseKey(hCommandKey);
1209  }
1210 
1211  RegCloseKey(hVerbKey);
1212  }
1213  SendDlgItemMessageW(hwndDlg, IDC_EDITTYPE_LISTBOX, LB_ADDSTRING, 0, LPARAM(szVerbName));
1214  ++dwIndex;
1215  }
1216 
1217  RegCloseKey(hShellKey);
1219 
1220  return TRUE;
1221 }
1222 
1223 static void
1225 {
1226  PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1227 
1228  // get class name
1229  GetDlgItemTextW(hwndDlg, IDC_EDITTYPE_TEXT, pEntry->ClassName, _countof(pEntry->ClassName));
1230  StrTrimW(pEntry->ClassName, g_pszSpace);
1231 
1232  // update entry icon
1233  EditTypeDlg_UpdateEntryIcon(hwndDlg, pEditType, pEditType->szIconPath, pEditType->nIconIndex);
1234 
1235  // write registry
1236  EditTypeDlg_WriteClass(hwndDlg, pEditType, pEntry->ClassKey, pEntry->ClassName,
1237  _countof(pEntry->ClassName));
1238 
1239  // update the icon cache
1241 
1242  EndDialog(hwndDlg, IDOK);
1243 }
1244 
1245 static BOOL
1247 {
1248  // get current selection
1249  INT iItem = SendDlgItemMessageW(hwndDlg, IDC_EDITTYPE_LISTBOX, LB_GETCURSEL, 0, 0);
1250  if (iItem == LB_ERR)
1251  return FALSE;
1252 
1253  // ask user for removal
1256  if (MessageBoxW(hwndDlg, strText, strTitle, MB_ICONINFORMATION | MB_YESNO) == IDNO)
1257  return FALSE;
1258 
1259  // get text
1260  WCHAR szText[64];
1261  szText[0] = 0;
1264 
1265  // remove it
1266  pEditType->CommandLineMap.Remove(szText);
1268  return TRUE;
1269 }
1270 
1271 static void
1273 {
1274  INT iItem, iIndex;
1276  switch (id)
1277  {
1278  case IDOK:
1279  EditTypeDlg_OnOK(hwndDlg, pEditType);
1280  break;
1281 
1282  case IDCANCEL:
1283  EndDialog(hwndDlg, IDCANCEL);
1284  break;
1285 
1287  EditTypeDlg_OnChangeIcon(hwndDlg, pEditType);
1288  break;
1289 
1290  case IDC_EDITTYPE_NEW:
1291  action.bUseDDE = FALSE;
1292  action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1293  StringCbPrintfW(action.ClassName, sizeof(action.ClassName), pEditType->pEntry->ClassName);
1294  // open 'New Action' dialog
1297  {
1298  if (SendMessageW(action.hwndLB, LB_FINDSTRING, -1, (LPARAM)action.szAction) != LB_ERR)
1299  {
1300  // already exists, error
1301  HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_ACTION);
1302  SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
1303  SetFocus(hwndCtrl);
1304 
1305  CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_FILE_TYPES));
1306  strText.Format(IDS_ACTION_EXISTS, action.szAction);
1307  MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
1308  }
1309  else
1310  {
1311  // add it
1312  CStringW strCommandLine = action.szApp;
1313  strCommandLine += L" \"%1\"";
1314  pEditType->CommandLineMap.SetAt(action.szAction, strCommandLine);
1315  SendMessageW(action.hwndLB, LB_ADDSTRING, 0, LPARAM(action.szAction));
1316  if (SendMessageW(action.hwndLB, LB_GETCOUNT, 0, 0) == 1)
1317  {
1318  // set default
1319  StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), action.szAction);
1320  InvalidateRect(action.hwndLB, NULL, TRUE);
1321  }
1322  }
1323  }
1324  break;
1325 
1326  case IDC_EDITTYPE_LISTBOX:
1327  if (code == LBN_SELCHANGE)
1328  {
1329  action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1330  INT iItem = SendMessageW(action.hwndLB, LB_GETCURSEL, 0, 0);
1331  SendMessageW(action.hwndLB, LB_GETTEXT, iItem, LPARAM(action.szAction));
1332  if (lstrcmpiW(action.szAction, pEditType->szDefaultVerb) == 0)
1333  {
1335  }
1336  else
1337  {
1339  }
1340  break;
1341  }
1342  else if (code != LBN_DBLCLK)
1343  {
1344  break;
1345  }
1346  // FALL THROUGH
1347 
1349  action.bUseDDE = FALSE;
1350  action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1351  StringCbPrintfW(action.ClassName, sizeof(action.ClassName), pEditType->pEntry->ClassName);
1352  iItem = SendMessageW(action.hwndLB, LB_GETCURSEL, 0, 0);
1353  if (iItem == LB_ERR)
1354  break;
1355 
1356  // get action
1357  SendMessageW(action.hwndLB, LB_GETTEXT, iItem, LPARAM(action.szAction));
1358 
1359  // get app
1360  {
1361  iIndex = pEditType->CommandLineMap.FindKey(action.szAction);
1362  CStringW str = pEditType->CommandLineMap.GetValueAt(iIndex);
1363  StringCbCopyW(action.szApp, sizeof(action.szApp), LPCWSTR(str));
1364  }
1365 
1366  // open dialog
1369  {
1370  SendMessageW(action.hwndLB, LB_DELETESTRING, iItem, 0);
1371  SendMessageW(action.hwndLB, LB_INSERTSTRING, iItem, LPARAM(action.szAction));
1372  pEditType->CommandLineMap.SetAt(action.szAction, action.szApp);
1373  }
1374  break;
1375 
1376  case IDC_EDITTYPE_REMOVE:
1377  EditTypeDlg_OnRemove(hwndDlg, pEditType);
1378  break;
1379 
1381  action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1382  iItem = SendMessageW(action.hwndLB, LB_GETCURSEL, 0, 0);
1383  if (iItem == LB_ERR)
1384  break;
1385 
1386  SendMessageW(action.hwndLB, LB_GETTEXT, iItem, LPARAM(action.szAction));
1387 
1388  // set default
1389  StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), action.szAction);
1391  InvalidateRect(action.hwndLB, NULL, TRUE);
1392  break;
1393  }
1394 }
1395 
1396 static BOOL
1398 {
1399  PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1400  StringCbCopyW(pEditType->szIconPath, sizeof(pEditType->szIconPath), pEntry->IconPath);
1401  pEditType->nIconIndex = pEntry->nIconIndex;
1402  StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), L"open");
1403 
1404  // set info
1406  SetDlgItemTextW(hwndDlg, IDC_EDITTYPE_TEXT, pEntry->ClassName);
1407  EditTypeDlg_ReadClass(hwndDlg, pEditType, pEntry->ClassKey);
1409 
1410  // is listbox empty?
1411  if (SendDlgItemMessageW(hwndDlg, IDC_EDITTYPE_LISTBOX, LB_GETCOUNT, 0, 0) == 0)
1412  {
1416  }
1417  else
1418  {
1419  // select first item
1421  }
1422 
1424 
1425  return TRUE;
1426 }
1427 
1428 // IDD_EDITTYPE
1429 static INT_PTR CALLBACK
1431 {
1432  static PEDITTYPE_DIALOG s_pEditType = NULL;
1433  LPDRAWITEMSTRUCT pDraw;
1434  LPMEASUREITEMSTRUCT pMeasure;
1435 
1436  switch (uMsg)
1437  {
1438  case WM_INITDIALOG:
1439  s_pEditType = (PEDITTYPE_DIALOG)lParam;
1440  return EditTypeDlg_OnInitDialog(hwndDlg, s_pEditType);
1441 
1442  case WM_DRAWITEM:
1443  pDraw = LPDRAWITEMSTRUCT(lParam);
1444  return EditTypeDlg_OnDrawItem(hwndDlg, pDraw, s_pEditType);
1445 
1446  case WM_MEASUREITEM:
1447  pMeasure = LPMEASUREITEMSTRUCT(lParam);
1448  return EditTypeDlg_OnMeasureItem(hwndDlg, pMeasure, s_pEditType);
1449 
1450  case WM_COMMAND:
1451  EditTypeDlg_OnCommand(hwndDlg, LOWORD(wParam), HIWORD(wParam), s_pEditType);
1452  break;
1453  }
1454 
1455  return 0;
1456 }
1457 
1459 // FileTypesDlg
1460 
1461 static INT CALLBACK
1462 FileTypesDlg_CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
1463 {
1464  PFILE_TYPE_ENTRY Entry1, Entry2;
1465  int x;
1466 
1467  Entry1 = (PFILE_TYPE_ENTRY)lParam1;
1468  Entry2 = (PFILE_TYPE_ENTRY)lParam2;
1469 
1470  x = wcsicmp(Entry1->FileExtension, Entry2->FileExtension);
1471  if (x != 0)
1472  return x;
1473 
1474  return wcsicmp(Entry1->FileDescription, Entry2->FileDescription);
1475 }
1476 
1477 static VOID
1479 {
1480  RECT clientRect;
1481  LVCOLUMNW col;
1482  WCHAR szName[50];
1483  DWORD dwStyle;
1484  INT columnSize = 140;
1485 
1487  {
1488  // default to english
1489  wcscpy(szName, L"Extensions");
1490  }
1491 
1492  // make sure its null terminated
1493  szName[_countof(szName) - 1] = 0;
1494 
1495  GetClientRect(hListView, &clientRect);
1496  ZeroMemory(&col, sizeof(LV_COLUMN));
1497  columnSize = 120;
1498  col.iSubItem = 0;
1500  col.fmt = LVCFMT_FIXED_WIDTH;
1501  col.cx = columnSize | LVCFMT_LEFT;
1502  col.cchTextMax = wcslen(szName);
1503  col.pszText = szName;
1505 
1507  {
1508  // default to english
1509  wcscpy(szName, L"File Types");
1510  ERR("Failed to load localized string!\n");
1511  }
1512 
1513  col.iSubItem = 1;
1514  col.cx = clientRect.right - clientRect.left - columnSize;
1515  col.cchTextMax = wcslen(szName);
1516  col.pszText = szName;
1518 
1519  // set full select style
1521  dwStyle = dwStyle | LVS_EX_FULLROWSELECT;
1523 }
1524 
1525 static PFILE_TYPE_ENTRY
1527 {
1528  HWND hListView;
1529  DWORD dwIndex = 0;
1530  WCHAR szName[50];
1531  WCHAR szFile[100];
1532  DWORD dwName;
1533  LVITEMW lvItem;
1534  INT iItem = 0;
1535  HIMAGELIST himlLarge, himlSmall;
1536 
1537  // create imagelists
1539  ILC_COLOR32 | ILC_MASK, 256, 20);
1541  ILC_COLOR32 | ILC_MASK, 256, 20);
1542 
1543  // set imagelists to listview.
1547 
1549 
1550  szFile[0] = 0;
1551  if (!LoadStringW(shell32_hInstance, IDS_FILE_EXT_TYPE, szFile, _countof(szFile)))
1552  {
1553  // default to english
1554  wcscpy(szFile, L"%s File");
1555  }
1556  szFile[(_countof(szFile)) - 1] = 0;
1557 
1558  dwName = _countof(szName);
1559 
1560  while (RegEnumKeyExW(HKEY_CLASSES_ROOT, dwIndex++, szName, &dwName,
1561  NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
1562  {
1563  if (FileTypesDlg_InsertToLV(hListView, szName, iItem, szFile))
1564  ++iItem;
1565  dwName = _countof(szName);
1566  }
1567 
1568  // Leave if the list is empty
1569  if (iItem == 0)
1570  return NULL;
1571 
1572  // sort list
1574 
1575  // select first item
1576  ZeroMemory(&lvItem, sizeof(LVITEMW));
1577  lvItem.mask = LVIF_STATE;
1578  lvItem.stateMask = (UINT)-1;
1579  lvItem.state = LVIS_FOCUSED | LVIS_SELECTED;
1580  lvItem.iItem = 0;
1581  ListView_SetItem(hListView, &lvItem);
1582 
1583  lvItem.mask = LVIF_PARAM;
1584  ListView_GetItem(hListView, &lvItem);
1585 
1586  return (PFILE_TYPE_ENTRY)lvItem.lParam;
1587 }
1588 
1589 static inline PFILE_TYPE_ENTRY
1591 {
1592  if (iItem == -1)
1593  {
1595  if (iItem == -1)
1596  return NULL;
1597  }
1598 
1599  LV_ITEMW lvItem = { LVIF_PARAM, iItem };
1600  if (ListView_GetItem(hListView, &lvItem))
1601  return (PFILE_TYPE_ENTRY)lvItem.lParam;
1602 
1603  return NULL;
1604 }
1605 
1606 static void
1608 {
1609  CStringW strRemoveExt(MAKEINTRESOURCEW(IDS_REMOVE_EXT));
1611  if (MessageBoxW(hwndDlg, strRemoveExt, strTitle, MB_ICONQUESTION | MB_YESNO) == IDYES)
1612  {
1613  FileTypesDlg_RemoveExt(hwndDlg);
1614  }
1615 }
1616 
1617 static void
1619 {
1620  WCHAR Buffer[255];
1621  static HBITMAP s_hbmProgram = NULL;
1622 
1623  // format buffer and set groupbox text
1625  StringCbPrintfW(Buffer, sizeof(Buffer), strFormat, &pEntry->FileExtension[1]);
1627 
1628  // format buffer and set description
1629  strFormat.LoadString(IDS_FILE_DETAILSADV);
1630  StringCbPrintfW(Buffer, sizeof(Buffer), strFormat,
1631  &pEntry->FileExtension[1], pEntry->FileDescription,
1632  pEntry->FileDescription);
1634 
1635  // delete previous program image
1636  if (s_hbmProgram)
1637  {
1638  DeleteObject(s_hbmProgram);
1639  s_hbmProgram = NULL;
1640  }
1641 
1642  // set program image
1643  HICON hIconSm = NULL;
1644  ExtractIconExW(pEntry->ProgramPath, 0, NULL, &hIconSm, 1);
1645  s_hbmProgram = BitmapFromIcon(hIconSm, 16, 16);
1648 
1649  // set program name
1650  if (pEntry->AppName[0])
1651  SetDlgItemTextW(hwndDlg, IDC_FILETYPES_APPNAME, pEntry->AppName);
1652  else
1653  SetDlgItemTextW(hwndDlg, IDC_FILETYPES_APPNAME, L"ReactOS");
1654 
1655  // Enable the Delete button
1656  if (pEntry->EditFlags & 0x00000010) // FTA_NoRemove
1658  else
1660 }
1661 
1662 // IDD_FOLDER_OPTIONS_FILETYPES
1665  HWND hwndDlg,
1666  UINT uMsg,
1667  WPARAM wParam,
1668  LPARAM lParam)
1669 {
1670  LPNMLISTVIEW lppl;
1671  PFILE_TYPE_ENTRY pEntry;
1672  OPENASINFO Info;
1673  NEWEXT_DIALOG newext;
1674  EDITTYPE_DIALOG edittype;
1675 
1676  switch (uMsg)
1677  {
1678  case WM_INITDIALOG:
1679  pEntry = FileTypesDlg_DoList(hwndDlg);
1680 
1681  // Disable the Delete button if the listview is empty
1682  // the selected item should not be deleted by the user
1683  if (pEntry == NULL || (pEntry->EditFlags & 0x00000010)) // FTA_NoRemove
1685  return TRUE;
1686 
1687  case WM_COMMAND:
1688  switch (LOWORD(wParam))
1689  {
1690  case IDC_FILETYPES_NEW:
1691  newext.hwndLV = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1693  hwndDlg, NewExtDlgProc, (LPARAM)&newext))
1694  {
1695  FileTypesDlg_AddExt(hwndDlg, newext.szExt, newext.szFileType);
1696  }
1697  break;
1698 
1699  case IDC_FILETYPES_DELETE:
1700  FileTypesDlg_OnDelete(hwndDlg);
1701  break;
1702 
1703  case IDC_FILETYPES_CHANGE:
1705  if (pEntry)
1706  {
1707  ZeroMemory(&Info, sizeof(Info));
1709  Info.pcszFile = pEntry->FileExtension;
1710  Info.pcszClass = NULL;
1711  SHOpenWithDialog(hwndDlg, &Info);
1712  }
1713  break;
1714 
1716  edittype.hwndLV = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1717  edittype.pEntry = FileTypesDlg_GetEntry(edittype.hwndLV);
1719  hwndDlg, EditTypeDlgProc, (LPARAM)&edittype);
1720  break;
1721  }
1722  break;
1723 
1724  case WM_NOTIFY:
1725  lppl = (LPNMLISTVIEW) lParam;
1726  switch (lppl->hdr.code)
1727  {
1728  case LVN_KEYDOWN:
1729  {
1730  LV_KEYDOWN *pKeyDown = (LV_KEYDOWN *)lParam;
1731  if (pKeyDown->wVKey == VK_DELETE)
1732  {
1733  FileTypesDlg_OnDelete(hwndDlg);
1734  }
1735  break;
1736  }
1737 
1738  case NM_DBLCLK:
1739  edittype.hwndLV = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1740  edittype.pEntry = FileTypesDlg_GetEntry(edittype.hwndLV);
1742  hwndDlg, EditTypeDlgProc, (LPARAM)&edittype);
1743  break;
1744 
1745  case LVN_DELETEALLITEMS:
1746  return FALSE; // send LVN_DELETEITEM
1747 
1748  case LVN_DELETEITEM:
1749  pEntry = FileTypesDlg_GetEntry(lppl->hdr.hwndFrom, lppl->iItem);
1750  if (pEntry)
1751  {
1752  DestroyIcon(pEntry->hIconLarge);
1753  DestroyIcon(pEntry->hIconSmall);
1754  HeapFree(GetProcessHeap(), 0, pEntry);
1755  }
1756  return FALSE;
1757 
1758  case LVN_ITEMCHANGING:
1759  pEntry = FileTypesDlg_GetEntry(lppl->hdr.hwndFrom, lppl->iItem);
1760  if (!pEntry)
1761  {
1762  return TRUE;
1763  }
1764 
1765  if (!(lppl->uOldState & LVIS_FOCUSED) && (lppl->uNewState & LVIS_FOCUSED))
1766  {
1767  FileTypesDlg_OnItemChanging(hwndDlg, pEntry);
1768  }
1769  break;
1770 
1771  case PSN_SETACTIVE:
1772  // On page activation, set the focus to the listview
1774  break;
1775  }
1776  break;
1777  }
1778 
1779  return FALSE;
1780 }
static void DoFileTypeIconLocation(PFILE_TYPE_ENTRY Entry, LPCWSTR IconLocation)
Definition: filetypes.cpp:111
#define IDS_ACTION_EXISTS
Definition: shresdef.h:278
static BOOL EditTypeDlg_OnInitDialog(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1397
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
WCHAR FileDescription[100]
Definition: filetypes.cpp:35
#define LB_SETCURSEL
Definition: winuser.h:2024
#define ListView_EnsureVisible(hwndLV, i, fPartialOK)
Definition: commctrl.h:2491
struct tagMEASUREITEMSTRUCT * LPMEASUREITEMSTRUCT
#define LV_ITEM
Definition: commctrl.h:2309
#define IDS_EDITING_ACTION
Definition: shresdef.h:280
#define STM_SETICON
Definition: winuser.h:2053
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2406
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
static HICON
Definition: imagelist.c:84
int iImage
Definition: commctrl.h:2339
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2195
HDWP WINAPI BeginDeferWindowPos(_In_ int)
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define COLOR_HIGHLIGHT
Definition: winuser.h:916
struct NEWEXT_DIALOG NEWEXT_DIALOG
#define IMAGE_ICON
Definition: winuser.h:212
#define IDD_ACTION
Definition: shresdef.h:442
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
struct NEWEXT_DIALOG * PNEWEXT_DIALOG
#define LVCF_WIDTH
Definition: commctrl.h:2559
static BOOL EditTypeDlg_ReadClass(HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR ClassKey)
Definition: filetypes.cpp:1157
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define LISTBOX_MARGIN
Definition: filetypes.cpp:205
#define LVSIL_SMALL
Definition: commctrl.h:2271
#define IDI_SHELL_FOLDER_OPTIONS
Definition: shresdef.h:573
#define SW_SHOWNOACTIVATE
Definition: winuser.h:768
WCHAR ClassKey[MAX_PATH]
Definition: filetypes.cpp:36
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDC_EDITTYPE_SAME_WINDOW
Definition: shresdef.h:420
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
UINT uNewState
Definition: commctrl.h:3008
#define ListView_SetItem(hwnd, pitem)
Definition: commctrl.h:2373
struct _Entry Entry
Definition: kefuncs.h:640
#define IDYES
Definition: winuser.h:829
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static BOOL NewExtDlg_OnOK(HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
Definition: filetypes.cpp:447
#define LB_ADDSTRING
Definition: winuser.h:1992
#define LVCF_TEXT
Definition: commctrl.h:2560
#define IDC_NEWEXT_EDIT
Definition: shresdef.h:379
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
HDC WINAPI GetDC(_In_opt_ HWND)
HWND hwndOwner
Definition: commdlg.h:330
#define REG_BINARY
Definition: nt_native.h:1496
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define KEY_READ
Definition: nt_native.h:1023
LPCWSTR g_pszShell32
#define SW_HIDE
Definition: winuser.h:762
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define IDS_COLUMN_EXTENSION
Definition: shresdef.h:133
#define IDC_ACTION_ACTION
Definition: shresdef.h:423
#define IDS_INVALID_PROGRAM
Definition: shresdef.h:276
#define _countof(array)
Definition: fontsub.cpp:30
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define EM_SETLIMITTEXT
Definition: winuser.h:1972
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2656
struct EDITTYPE_DIALOG * PEDITTYPE_DIALOG
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:286
#define LV_COLUMN
Definition: commctrl.h:2519
static PFILE_TYPE_ENTRY FileTypesDlg_DoList(HWND hwndDlg)
Definition: filetypes.cpp:1526
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
PFILE_TYPE_ENTRY pEntry
Definition: filetypes.cpp:210
WCHAR szFileType[64]
Definition: filetypes.cpp:347
#define LV_KEYDOWN
Definition: commctrl.h:3158
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
#define IDC_FILETYPES_APPNAME
Definition: shresdef.h:372
DWORD EditFlags
Definition: filetypes.cpp:38
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2706
LONG top
Definition: windef.h:292
HICON hIconLarge
Definition: filetypes.cpp:40
WCHAR szIconPath[MAX_PATH]
Definition: filetypes.cpp:212
OPENFILENAME ofn
Definition: main.cpp:37
#define LVCFMT_LEFT
Definition: commctrl.h:2570
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ODS_FOCUS
Definition: winuser.h:2503
static INT_PTR CALLBACK EditActionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:966
#define ZeroMemory
Definition: winbase.h:1635
static void FileTypesDlg_OnItemChanging(HWND hwndDlg, PFILE_TYPE_ENTRY pEntry)
Definition: filetypes.cpp:1618
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LPCSTR lpstrDefExt
Definition: commdlg.h:345
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:668
#define SM_CYSMICON
Definition: winuser.h:1003
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static BOOL FileTypesDlg_AddExt(HWND hwndDlg, LPCWSTR pszExt, LPCWSTR pszFileType)
Definition: filetypes.cpp:708
HWND WINAPI SetFocus(_In_opt_ HWND)
WCHAR IconPath[MAX_PATH]
Definition: filetypes.cpp:43
#define IDC_ACTION_USE_DDE
Definition: shresdef.h:426
#define IDS_REMOVE_ACTION
Definition: shresdef.h:277
static BOOL NewExtDlg_OnInitDialog(HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
Definition: filetypes.cpp:421
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define LVNI_SELECTED
Definition: commctrl.h:2396
UINT_PTR WPARAM
Definition: windef.h:207
LONG left
Definition: windef.h:291
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT_PTR
Definition: typedefs.h:62
LONG right
Definition: windef.h:293
short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, WORD cbBuf)
Definition: filedlg.c:4341
#define DT_NOPREFIX
Definition: winuser.h:537
#define lstrlenW
Definition: compat.h:407
#define LV_FINDINFO
Definition: commctrl.h:2417
#define LBN_SELCHANGE
Definition: winuser.h:2036
#define PSN_SETACTIVE
Definition: prsht.h:115
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:56
DWORD WINAPI GetSysColor(_In_ int)
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
UINT stateMask
Definition: commctrl.h:2336
HFONT hFont
Definition: main.c:53
struct TraceInfo Info
static HICON DoExtractIcon(PFILE_TYPE_ENTRY Entry, LPCWSTR IconPath, INT iIndex=0, BOOL bSmall=FALSE)
Definition: filetypes.cpp:73
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:1094
#define MB_ICONWARNING
Definition: winuser.h:780
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
DWORD nMaxFile
Definition: commdlg.h:337
static BOOL EditTypeDlg_OnDrawItem(HWND hwndDlg, LPDRAWITEMSTRUCT pDraw, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:254
#define ILC_COLOR32
Definition: commctrl.h:343
#define LVN_ITEMCHANGING
Definition: commctrl.h:3102
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define LVIF_TEXT
Definition: commctrl.h:2281
#define LVCF_SUBITEM
Definition: commctrl.h:2561
UINT code
Definition: winuser.h:3112
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2706
#define IDC_EDITTYPE_EDIT_BUTTON
Definition: shresdef.h:415
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
#define IDC_FILETYPES_DETAILS_GROUPBOX
Definition: shresdef.h:371
#define LVN_KEYDOWN
Definition: commctrl.h:3156
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:769
unsigned char * LPBYTE
Definition: typedefs.h:52
static INT CALLBACK FileTypesDlg_CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: filetypes.cpp:1462
#define ListView_GetImageList(hwnd, iImageList)
Definition: commctrl.h:2268
#define IDC_FILETYPES_DESCRIPTION
Definition: shresdef.h:374
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define MB_YESNO
Definition: winuser.h:811
#define DT_LEFT
Definition: winuser.h:534
static const WCHAR szText[]
Definition: dialog.c:139
#define LB_ERR
Definition: winuser.h:2386
#define IDS_NEWEXT_EXT_IN_USE
Definition: shresdef.h:273
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2604
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
long LONG
Definition: pedump.c:60
#define IDC_EDITTYPE_ICON
Definition: shresdef.h:410
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:350
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:873
HICON hIconSmall
Definition: filetypes.cpp:41
int iSubItem
Definition: commctrl.h:2334
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define IDC_FILETYPES_ADVANCED
Definition: shresdef.h:375
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4221
#define IDC_NEWEXT_ASSOC
Definition: shresdef.h:382
LPARAM lParam
Definition: commctrl.h:2340
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
WCHAR FileExtension[30]
Definition: filetypes.cpp:34
#define SM_CXICON
Definition: winuser.h:962
#define IDS_REMOVE_EXT
Definition: shresdef.h:282
LPCWSTR g_pszSpace
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
#define LV_ITEMW
Definition: commctrl.h:2304
#define CB_ADDSTRING
Definition: winuser.h:1897
struct ACTION_DIALOG * PACTION_DIALOG
const WCHAR * str
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2276
struct FILE_TYPE_ENTRY FILE_TYPE_ENTRY
smooth NULL
Definition: ftsmooth.c:416
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define LVIS_SELECTED
Definition: commctrl.h:2291
#define WM_GETFONT
Definition: winuser.h:1633
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
static void ActionDlg_OnBrowse(HWND hwndDlg, PACTION_DIALOG pNewAct, BOOL bEdit=FALSE)
Definition: filetypes.cpp:818
#define MB_ICONQUESTION
Definition: winuser.h:783
UINT uOldState
Definition: commctrl.h:3009
LONG_PTR LPARAM
Definition: windef.h:208
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2383
LPTSTR szFilter
Definition: mplay32.c:30
CSimpleMap< CStringW, CStringW > CommandLineMap
Definition: filetypes.cpp:211
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2279
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:164
#define IDS_NEWEXT_SPECIFY_EXT
Definition: shresdef.h:271
Definition: bufpool.h:45
#define DT_VCENTER
Definition: winuser.h:543
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:917
_CRTIMP wchar_t *__cdecl _wcsupr(_Inout_z_ wchar_t *_String)
HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
Definition: assoc.c:427
INT nIconIndex
Definition: filetypes.cpp:44
#define LB_GETCOUNT
Definition: winuser.h:1999
#define IDS_SPECIFY_ACTION
Definition: shresdef.h:275
#define VK_DELETE
Definition: winuser.h:2187
#define IDC_EDITTYPE_REMOVE
Definition: shresdef.h:416
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
static INT_PTR CALLBACK NewExtDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:523
#define LVN_DELETEALLITEMS
Definition: commctrl.h:3106
static INT_PTR CALLBACK EditTypeDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:1430
WCHAR AppName[64]
Definition: filetypes.cpp:39
#define KEY_WRITE
Definition: nt_native.h:1031
#define IDS_FILE_EXT_TYPE
Definition: shresdef.h:178
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:4917
struct EDITTYPE_DIALOG EDITTYPE_DIALOG
#define FreeLibrary(x)
Definition: compat.h:405
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
LONG RegLoadMUIStringW(IN HKEY hKey, IN LPCWSTR pszValue OPTIONAL, OUT LPWSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCWSTR pszDirectory OPTIONAL)
Definition: muireg.c:53
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HRESULT WINAPI SHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:410
#define IDS_NEWEXT_ADVANCED_LEFT
Definition: shresdef.h:268
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define COLOR_WINDOWTEXT
Definition: winuser.h:911
static BOOL GetFileTypeIconsEx(PFILE_TYPE_ENTRY Entry, LPCWSTR IconLocation)
Definition: filetypes.cpp:125
#define IDS_FILE_DETAILS
Definition: shresdef.h:176
LPWSTR pszText
Definition: commctrl.h:2337
#define StringCbPrintf
Definition: strsafe.h:544
#define MAX_PATH
Definition: compat.h:26
DWORD lStructSize
Definition: commdlg.h:329
#define EM_SETSEL
Definition: winuser.h:1979
#define LVIF_IMAGE
Definition: commctrl.h:2282
struct ACTION_DIALOG ACTION_DIALOG
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
LPWSTR pszText
Definition: commctrl.h:2539
int WINAPI GetSystemMetrics(_In_ int)
#define LVN_DELETEITEM
Definition: commctrl.h:3105
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR szLocation[]
Definition: http.c:110
#define WM_MEASUREITEM
Definition: winuser.h:1628
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2696
#define IDC_EDITTYPE_LISTBOX
Definition: shresdef.h:413
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static BOOL DeleteExt(HWND hwndDlg, LPCWSTR pszExt)
Definition: filetypes.cpp:48
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:505
WCHAR szApp[MAX_PATH]
Definition: filetypes.cpp:813
#define GetObject
Definition: wingdi.h:4446
#define LBN_DBLCLK
Definition: winuser.h:2032
UINT mask
Definition: commctrl.h:2332
#define SM_CXSMICON
Definition: winuser.h:1002
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR IconIndex[]
Definition: install.c:51
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define IDS_FILE_TYPES
Definition: shresdef.h:175
#define SM_CYICON
Definition: winuser.h:963
WCHAR ClassName[64]
Definition: filetypes.cpp:37
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static PFILE_TYPE_ENTRY FileTypesDlg_GetEntry(HWND hListView, INT iItem=-1)
Definition: filetypes.cpp:1590
#define LB_GETTEXT
Definition: winuser.h:2010
static const WCHAR L[]
Definition: oid.c:1250
#define IDD_EDITTYPE
Definition: shresdef.h:441
static BOOL FileTypesDlg_RemoveExt(HWND hwndDlg)
Definition: filetypes.cpp:787
#define MB_ICONERROR
Definition: winuser.h:781
#define IDS_NEWEXT_ALREADY_ASSOC
Definition: shresdef.h:272
#define ILC_MASK
Definition: commctrl.h:336
#define IDC_EDITTYPE_NEW
Definition: shresdef.h:414
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define IDC_FILETYPES_NEW
Definition: shresdef.h:369
WCHAR szDefaultVerb[64]
Definition: filetypes.cpp:214
static void SetFileTypeEntryDefaultIcon(PFILE_TYPE_ENTRY Entry)
Definition: filetypes.cpp:191
#define LVSIL_NORMAL
Definition: commctrl.h:2270
#define CB_SETCURSEL
Definition: winuser.h:1922
static VOID FileTypesDlg_InitListView(HWND hwndDlg, HWND hListView)
Definition: filetypes.cpp:1478
Definition: time.h:76
#define WM_COMMAND
Definition: winuser.h:1716
HWND hwndFrom
Definition: winuser.h:3110
void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
Definition: changenotify.c:340
UINT state
Definition: commctrl.h:2335
#define IDC_ACTION_APP
Definition: shresdef.h:424
#define wcsicmp
Definition: string.h:1152
#define IDC_EDITTYPE_TEXT
Definition: shresdef.h:411
static void NewActionDlg_OnOK(HWND hwndDlg, PACTION_DIALOG pNewAct)
Definition: filetypes.cpp:857
#define LVM_GETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2699
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2430
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1087
#define IDI_SHELL_EXE
Definition: shresdef.h:466
int cchTextMax
Definition: commctrl.h:2540
#define ERR(fmt,...)
Definition: debug.h:109
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:884
static HDC hDC
Definition: 3dtext.c:33
_CRTIMP wchar_t *__cdecl _wcslwr(_Inout_z_ wchar_t *_String)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_SINGLELINE
Definition: winuser.h:540
#define LVM_INSERTITEMW
Definition: commctrl.h:2376
#define IDS_FILE_DETAILSADV
Definition: shresdef.h:177
#define LVCF_FMT
Definition: commctrl.h:2558
HWND hListView
Definition: gui.cpp:29
#define S_OK
Definition: intsafe.h:59
#define RegOpenKeyEx
Definition: winreg.h:520
#define OPENFILENAME_SIZE_VERSION_400W
Definition: commdlg.h:397
#define lstrlen
Definition: winbase.h:3690
#define LB_FINDSTRING
Definition: winuser.h:1995
static void EditTypeDlg_OnCommand(HWND hwndDlg, UINT id, UINT code, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1272
static void EditTypeDlg_OnChangeIcon(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:218
const WCHAR * action
Definition: action.c:7783
#define FW_BOLD
Definition: wingdi.h:377
static ATOM item
Definition: dde.c:856
WINE_DEFAULT_DEBUG_CHANNEL(fprop)
#define IDC_FILETYPES_DELETE
Definition: shresdef.h:370
#define NM_DBLCLK
Definition: commctrl.h:131
LPSTR lpstrFile
Definition: commdlg.h:336
struct tagNMLISTVIEW * LPNMLISTVIEW
HICON hIcon
Definition: msconfig.c:44
LPCWSTR szPath
Definition: env.c:35
#define IDS_OPEN_WITH
Definition: shresdef.h:126
static void EditActionDlg_OnOK(HWND hwndDlg, PACTION_DIALOG pEditAct)
Definition: filetypes.cpp:931
WCHAR szExt[16]
Definition: filetypes.cpp:346
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static BOOL GetFileTypeIconsByKey(HKEY hKey, PFILE_TYPE_ENTRY Entry)
Definition: filetypes.cpp:154
#define IDC_EDITTYPE_CHANGE_ICON
Definition: shresdef.h:412
static BOOL EditTypeDlg_WriteClass(HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR ClassKey, LPCWSTR ClassName, INT cchName)
Definition: filetypes.cpp:1055
LPCSTR lpstrFilter
Definition: commdlg.h:332
#define LB_GETCURSEL
Definition: winuser.h:2000
#define IDC_FILETYPES_CHANGE
Definition: shresdef.h:373
unsigned int UINT
Definition: ndis.h:50
#define IMAGE_BITMAP
Definition: winuser.h:211
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define STM_SETIMAGE
Definition: winuser.h:2054
#define IDS_EXE_FILTER
Definition: shresdef.h:279
#define IDC_FILETYPES_LISTVIEW
Definition: shresdef.h:368
static const WCHAR IconPath[]
Definition: install.c:50
static BOOL EditTypeDlg_OnMeasureItem(HWND hwndDlg, LPMEASUREITEMSTRUCT pMeasure, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:318
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1869
#define IDS_NEWEXT_NEW
Definition: shresdef.h:270
#define WM_DRAWITEM
Definition: winuser.h:1627
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define IDC_FILETYPES_ICON
Definition: shresdef.h:376
static TAGID TAGID find
Definition: db.cpp:153
_Out_opt_ int * cx
Definition: commctrl.h:570
LPCSTR lpstrTitle
Definition: commdlg.h:341
#define LVFI_STRING
Definition: commctrl.h:2409
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2442
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2366
static const WCHAR szName[]
Definition: msipriv.h:1194
#define ODS_SELECTED
Definition: winuser.h:2499
#define ListView_SortItems(hwndLV, _pfnCompare, _lPrm)
Definition: commctrl.h:2675
#define SendMessage
Definition: winuser.h:5709
#define LVIF_PARAM
Definition: commctrl.h:2283
HICON hIconSm
Definition: msconfig.c:44
HBITMAP BitmapFromIcon(HICON hIcon, INT cx, INT cy)
#define HIWORD(l)
Definition: typedefs.h:246
struct FILE_TYPE_ENTRY * PFILE_TYPE_ENTRY
BOOL LoadString(_In_ UINT nID)
Definition: cstringt.h:506
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
LONG bottom
Definition: windef.h:294
INT_PTR CALLBACK FolderOptionsFileTypesDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:1664
CAtlStringW CStringW
Definition: atlstr.h:130
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
static BOOL EditTypeDlg_OnRemove(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1246
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
static HBITMAP
Definition: button.c:44
static const WCHAR rc2[]
Definition: oid.c:1216
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2541
#define IDNO
Definition: winuser.h:830
static void EditTypeDlg_OnOK(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1224
LONG lfWeight
Definition: dimm.idl:63
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define LVIF_STATE
Definition: commctrl.h:2284
#define IDS_NEWEXT_ADVANCED_RIGHT
Definition: shresdef.h:269
#define IDC_ACTION_BROWSE
Definition: shresdef.h:425
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
static BOOL QueryFileDescription(LPCWSTR ProgramPath, LPWSTR pszName, INT cchName)
Definition: filetypes.cpp:178
#define LB_DELETESTRING
Definition: winuser.h:1993
#define OFN_ENABLESIZING
Definition: commdlg.h:101
#define IDD_NEWEXTENSION
Definition: shresdef.h:440
static INT_PTR CALLBACK NewActionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:895
#define IDC_NEWEXT_ADVANCED
Definition: shresdef.h:380
Definition: filetypes.cpp:32
WCHAR ClassName[64]
Definition: filetypes.cpp:811
#define REG_DWORD
Definition: sdbapi.c:596
static VOID NewExtDlg_OnAdvanced(HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
Definition: filetypes.cpp:351
#define IDC_NEWEXT_COMBOBOX
Definition: shresdef.h:381
static void FileTypesDlg_OnDelete(HWND hwndDlg)
Definition: filetypes.cpp:1607
#define WM_INITDIALOG
Definition: winuser.h:1715
#define LB_INSERTSTRING
Definition: winuser.h:2014
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static BOOL FileTypesDlg_InsertToLV(HWND hListView, LPCWSTR szName, INT iItem, LPCWSTR szFile)
Definition: filetypes.cpp:560
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
static BOOL EditTypeDlg_UpdateEntryIcon(HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR IconPath, INT IconIndex)
Definition: filetypes.cpp:1011
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define RegCreateKeyEx
Definition: winreg.h:501
WCHAR szAction[64]
Definition: filetypes.cpp:812
base of all file and directory entries
Definition: entries.h:82
#define LVIS_FOCUSED
Definition: commctrl.h:2290
#define WM_NOTIFY
Definition: richedit.h:61
#define IDC_EDITTYPE_SET_DEFAULT
Definition: shresdef.h:417
#define SHCNF_FLUSHNOWAIT
Definition: shlobj.h:1759
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
Definition: path.c:42
static HKEY hClassKey
Definition: umpnpmgr.c:65
DWORD Flags
Definition: commdlg.h:342
#define SHCNE_ASSOCCHANGED
Definition: shlobj.h:1741
#define REG_SZ
Definition: layer.c:22
WCHAR ProgramPath[MAX_PATH]
Definition: filetypes.cpp:42