ReactOS 0.4.16-dev-329-g9223134
filetypes.cpp File Reference
#include "precomp.h"
#include <atlpath.h>
Include dependency graph for filetypes.cpp:

Go to the source code of this file.

Classes

struct  _FILE_TYPE_ENTRY
 
struct  _FILE_TYPE_GLOBALS
 
struct  EDITTYPE_DIALOG
 
struct  NEWEXT_DIALOG
 
struct  ACTION_DIALOG
 

Macros

#define FTA_MODIFYMASK   (FTA_OpenIsSafe)
 
#define NOASSOCRESID   IDI_SHELL_DOCUMENT
 
#define SUPPORT_EXTENSIONWITHOUTPROGID   1
 
#define ASSOC_CCHMAX   (32 + 1)
 
#define TYPENAME_CCHMAX   max(100, RTL_FIELD_SIZE(SHFILEINFOA, szTypeName))
 
#define ICONLOCATION_CCHMAX   (MAX_PATH + 1 + 11)
 
#define LISTBOX_MARGIN   2
 

Typedefs

typedef struct _FILE_TYPE_ENTRY FILE_TYPE_ENTRY
 
typedef struct _FILE_TYPE_ENTRYPFILE_TYPE_ENTRY
 
typedef struct _FILE_TYPE_GLOBALS FILE_TYPE_GLOBALS
 
typedef struct _FILE_TYPE_GLOBALSPFILE_TYPE_GLOBALS
 
typedef struct EDITTYPE_DIALOG EDITTYPE_DIALOG
 
typedef struct EDITTYPE_DIALOGPEDITTYPE_DIALOG
 
typedef struct NEWEXT_DIALOG NEWEXT_DIALOG
 
typedef struct NEWEXT_DIALOGPNEWEXT_DIALOG
 
typedef struct ACTION_DIALOG ACTION_DIALOG
 
typedef struct ACTION_DIALOGPACTION_DIALOG
 

Enumerations

enum  EDITTYPEFLAGS { ETF_ALWAYSEXT = 1 << 0 , ETF_BROWSESAME = 1 << 1 }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (fprop)
 
EXTERN_C BOOL PathIsExeW (LPCWSTR lpszPath)
 
static DWORD GetRegDWORD (HKEY hKey, LPCWSTR Name, DWORD &Value, DWORD DefaultValue=0, BOOL Strict=FALSE)
 
static DWORD GetRegDWORD (HKEY hKey, LPCWSTR Name, DWORD DefaultValue=0)
 
static HRESULT GetClassKey (const FILE_TYPE_ENTRY &FTE, LPCWSTR &SubKey)
 
static void QuoteAppPathForCommand (CStringW &path)
 
static BOOL DeleteExt (HWND hwndDlg, LPCWSTR pszExt)
 
static HICON DoExtractIcon (LPCWSTR IconPath, INT iIndex, UINT cx, UINT cy)
 
static HICON DoExtractIcon (LPCWSTR IconPath, INT iIndex=0, BOOL bSmall=FALSE)
 
static BOOL GetFileTypeIconsEx (PFILE_TYPE_ENTRY Entry, LPCWSTR IconLocation, UINT IconSize)
 
static BOOL GetFileTypeIconsByKey (HKEY hKey, PFILE_TYPE_ENTRY Entry, UINT IconSize)
 
static LPCWSTR GetProgramPath (PFILE_TYPE_ENTRY Entry)
 
static BOOL QueryFileDescription (LPCWSTR ProgramPath, LPWSTR pszName, INT cchName)
 
static LPCWSTR GetAppName (PFILE_TYPE_ENTRY Entry)
 
static LPWSTR GetTypeName (PFILE_TYPE_ENTRY Entry, PFILE_TYPE_GLOBALS pG)
 
static void InitializeDefaultIcons (PFILE_TYPE_GLOBALS pG)
 
static BOOL Normalize (PFILE_TYPE_ENTRY Entry)
 
static void EditTypeDlg_OnChangeIcon (HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
 
static BOOL EditTypeDlg_OnDrawItem (HWND hwndDlg, LPDRAWITEMSTRUCT pDraw, PEDITTYPE_DIALOG pEditType)
 
static BOOL EditTypeDlg_OnMeasureItem (HWND hwndDlg, LPMEASUREITEMSTRUCT pMeasure, PEDITTYPE_DIALOG pEditType)
 
static VOID NewExtDlg_OnAdvanced (HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
 
static BOOL NewExtDlg_OnInitDialog (HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
 
static BOOL NewExtDlg_OnOK (HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
 
static INT_PTR CALLBACK NewExtDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static PFILE_TYPE_ENTRY FileTypesDlg_InsertToLV (HWND hListView, LPCWSTR Assoc, INT iItem, PFILE_TYPE_GLOBALS pG)
 
static BOOL FileTypesDlg_AddExt (HWND hwndDlg, LPCWSTR pszExt, LPCWSTR pszProgId, PFILE_TYPE_GLOBALS pG)
 
static BOOL FileTypesDlg_RemoveExt (HWND hwndDlg)
 
static void ActionDlg_OnBrowse (HWND hwndDlg, PACTION_DIALOG pNewAct, BOOL bEdit=FALSE)
 
static void NewActionDlg_OnOK (HWND hwndDlg, PACTION_DIALOG pNewAct)
 
static INT_PTR CALLBACK NewActionDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static void EditActionDlg_OnOK (HWND hwndDlg, PACTION_DIALOG pEditAct)
 
static INT_PTR CALLBACK EditActionDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static void EditTypeDlg_Restrict (HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
 
static BOOL EditTypeDlg_UpdateEntryIcon (HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
 
static BOOL EditTypeDlg_WriteClass (HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR TypeName, EDITTYPEFLAGS Etf)
 
static BOOL EditTypeDlg_ReadClass (HWND hwndDlg, PEDITTYPE_DIALOG pEditType, EDITTYPEFLAGS &Etf)
 
static void EditTypeDlg_OnOK (HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
 
static BOOL EditTypeDlg_OnRemove (HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
 
static void EditTypeDlg_OnCommand (HWND hwndDlg, UINT id, UINT code, PEDITTYPE_DIALOG pEditType)
 
static BOOL EditTypeDlg_OnInitDialog (HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
 
static INT_PTR CALLBACK EditTypeDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT CALLBACK FileTypesDlg_CompareItems (LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
 
static void FileTypesDlg_Sort (PFILE_TYPE_GLOBALS pG, HWND hListView, INT Column=-1)
 
static VOID FileTypesDlg_InitListView (HWND hwndDlg, HWND hListView)
 
static void FileTypesDlg_SetGroupboxText (HWND hwndDlg, LPCWSTR Assoc)
 
static void FileTypesDlg_Refresh (HWND hwndDlg, HWND hListView, PFILE_TYPE_GLOBALS pG)
 
static PFILE_TYPE_GLOBALS FileTypesDlg_Initialize (HWND hwndDlg)
 
static PFILE_TYPE_ENTRY FileTypesDlg_GetEntry (HWND hListView, INT iItem=-1)
 
static void FileTypesDlg_OnDelete (HWND hwndDlg)
 
static void FileTypesDlg_OnItemChanging (HWND hwndDlg, PFILE_TYPE_ENTRY pEntry, PFILE_TYPE_GLOBALS pG)
 
INT_PTR CALLBACK FolderOptionsFileTypesDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ ASSOC_CCHMAX

#define ASSOC_CCHMAX   (32 + 1)

Definition at line 37 of file filetypes.cpp.

◆ FTA_MODIFYMASK

#define FTA_MODIFYMASK   (FTA_OpenIsSafe)

Definition at line 33 of file filetypes.cpp.

◆ ICONLOCATION_CCHMAX

#define ICONLOCATION_CCHMAX   (MAX_PATH + 1 + 11)

Definition at line 39 of file filetypes.cpp.

◆ LISTBOX_MARGIN

#define LISTBOX_MARGIN   2

Definition at line 355 of file filetypes.cpp.

◆ NOASSOCRESID

#define NOASSOCRESID   IDI_SHELL_DOCUMENT

Definition at line 34 of file filetypes.cpp.

◆ SUPPORT_EXTENSIONWITHOUTPROGID

#define SUPPORT_EXTENSIONWITHOUTPROGID   1

Definition at line 35 of file filetypes.cpp.

◆ TYPENAME_CCHMAX

#define TYPENAME_CCHMAX   max(100, RTL_FIELD_SIZE(SHFILEINFOA, szTypeName))

Definition at line 38 of file filetypes.cpp.

Typedef Documentation

◆ ACTION_DIALOG

◆ EDITTYPE_DIALOG

◆ FILE_TYPE_ENTRY

◆ FILE_TYPE_GLOBALS

◆ NEWEXT_DIALOG

◆ PACTION_DIALOG

◆ PEDITTYPE_DIALOG

◆ PFILE_TYPE_ENTRY

◆ PFILE_TYPE_GLOBALS

◆ PNEWEXT_DIALOG

Enumeration Type Documentation

◆ EDITTYPEFLAGS

Enumerator
ETF_ALWAYSEXT 
ETF_BROWSESAME 

Definition at line 357 of file filetypes.cpp.

357{ ETF_ALWAYSEXT = 1 << 0, ETF_BROWSESAME = 1 << 1 };
@ ETF_BROWSESAME
Definition: filetypes.cpp:357
@ ETF_ALWAYSEXT
Definition: filetypes.cpp:357

Function Documentation

◆ ActionDlg_OnBrowse()

static void ActionDlg_OnBrowse ( HWND  hwndDlg,
PACTION_DIALOG  pNewAct,
BOOL  bEdit = FALSE 
)
static

Definition at line 900 of file filetypes.cpp.

901{
902 WCHAR szFile[MAX_PATH];
903 szFile[0] = UNICODE_NULL;
904
907
909
911 ZeroMemory(&ofn, sizeof(ofn));
913 ofn.hwndOwner = hwndDlg;
915 ofn.lpstrFile = szFile;
916 ofn.nMaxFile = _countof(szFile);
917 ofn.lpstrTitle = strTitle;
919 ofn.lpstrDefExt = L"exe";
920 if (GetOpenFileNameW(&ofn))
921 {
922 if (bEdit)
923 {
924 CStringW str = szFile;
926 str += L" \"%1\"";
928 }
929 else
930 {
931 SetDlgItemTextW(hwndDlg, IDC_ACTION_APP, szFile);
932 }
933 }
934}
#define shell32_hInstance
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OPENFILENAME_SIZE_VERSION_400W
Definition: commdlg.h:397
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_ENABLESIZING
Definition: commdlg.h:101
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4736
#define MAX_PATH
Definition: compat.h:34
static void QuoteAppPathForCommand(CStringW &path)
Definition: filetypes.cpp:140
LPTSTR szFilter
Definition: mplay32.c:30
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
const WCHAR * str
#define IDS_EXE_FILTER
Definition: shresdef.h:335
#define IDC_ACTION_APP
Definition: shresdef.h:499
#define IDS_OPEN_WITH
Definition: shresdef.h:134
OPENFILENAME ofn
Definition: sndrec32.cpp:56
#define _countof(array)
Definition: sndvol32.h:70
LPCSTR lpstrDefExt
Definition: commdlg.h:345
HWND hwndOwner
Definition: commdlg.h:330
LPCSTR lpstrTitle
Definition: commdlg.h:341
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
#define ZeroMemory
Definition: winbase.h:1737
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by EditActionDlgProc(), and NewActionDlgProc().

◆ DeleteExt()

static BOOL DeleteExt ( HWND  hwndDlg,
LPCWSTR  pszExt 
)
static

Definition at line 147 of file filetypes.cpp.

148{
149 if (*pszExt != L'.')
150 return FALSE;
151
152 // open ".ext" key
153 HKEY hKey;
155 return FALSE;
156
157 // query "extfile" key name
158 WCHAR ProgId[MAX_PATH] = { 0 };
159 DWORD cb = sizeof(ProgId);
160 RegQueryValueExW(hKey, NULL, NULL, NULL, LPBYTE(ProgId), &cb);
162
163 // FIXME: Should verify that no other extensions are using this ProgId
164 // delete "extfile" key (if any)
165 if (ProgId[0])
167
168 // delete ".ext" key
170
171 // notify
173
174 return ret;
175}
#define RegCloseKey(hKey)
Definition: registry.h:49
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
#define KEY_READ
Definition: nt_native.h:1023
#define SHCNE_ASSOCCHANGED
Definition: shlobj.h:1911
#define SHCNF_FLUSHNOWAIT
Definition: shlobj.h:1929
unsigned char * LPBYTE
Definition: typedefs.h:53
int ret
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by FileTypesDlg_RemoveExt(), and NewExtDlg_OnOK().

◆ DoExtractIcon() [1/2]

static HICON DoExtractIcon ( LPCWSTR  IconPath,
INT  iIndex,
UINT  cx,
UINT  cy 
)
inlinestatic

Definition at line 178 of file filetypes.cpp.

179{
180 return SHELL32_SHExtractIcon(IconPath, iIndex, cx, cy);
181}
static const WCHAR IconPath[]
Definition: install.c:51
HICON SHELL32_SHExtractIcon(LPCWSTR File, int Index, int cx, int cy)
Definition: utils.h:42
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585

Referenced by DoExtractIcon(), EditTypeDlg_OnChangeIcon(), EditTypeDlg_OnInitDialog(), EditTypeDlg_UpdateEntryIcon(), and GetFileTypeIconsEx().

◆ DoExtractIcon() [2/2]

static HICON DoExtractIcon ( LPCWSTR  IconPath,
INT  iIndex = 0,
BOOL  bSmall = FALSE 
)
static

Definition at line 184 of file filetypes.cpp.

185{
188 return DoExtractIcon(IconPath, iIndex, cx, cy);
189}
static HICON DoExtractIcon(LPCWSTR IconPath, INT iIndex, UINT cx, UINT cy)
Definition: filetypes.cpp:178
unsigned int UINT
Definition: ndis.h:50
#define SM_CYSMICON
Definition: winuser.h:1016
#define SM_CXSMICON
Definition: winuser.h:1015
#define SM_CYICON
Definition: winuser.h:976
#define SM_CXICON
Definition: winuser.h:975
int WINAPI GetSystemMetrics(_In_ int)

◆ EditActionDlg_OnOK()

static void EditActionDlg_OnOK ( HWND  hwndDlg,
PACTION_DIALOG  pEditAct 
)
static

Definition at line 1014 of file filetypes.cpp.

1015{
1016 // check action
1017 GetDlgItemTextW(hwndDlg, IDC_ACTION_ACTION, pEditAct->szAction, _countof(pEditAct->szAction));
1018 StrTrimW(pEditAct->szAction, g_pszSpace);
1019 if (pEditAct->szAction[0] == 0)
1020 {
1021 // action was empty. show error
1022 HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_ACTION);
1023 SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
1024 SetFocus(hwndCtrl);
1027 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
1028 }
1029
1030 // check app
1031 GetDlgItemTextW(hwndDlg, IDC_ACTION_APP, pEditAct->szApp, _countof(pEditAct->szApp));
1032 StrTrimW(pEditAct->szApp, g_pszSpace);
1033 if (pEditAct->szApp[0] == 0)
1034 {
1035 // app was empty. show error
1036 HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_APP);
1037 SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
1038 SetFocus(hwndCtrl);
1041 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
1042 }
1043
1044 EndDialog(hwndDlg, IDOK);
1045}
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1883
LPCWSTR g_pszSpace
#define IDS_SPECIFY_ACTION
Definition: shresdef.h:331
#define IDS_INVALID_PROGRAM
Definition: shresdef.h:332
#define IDS_FILE_TYPES
Definition: shresdef.h:188
#define IDC_ACTION_ACTION
Definition: shresdef.h:498
WCHAR szAction[VERBKEY_CCHMAX]
Definition: filetypes.cpp:894
WCHAR szApp[MAX_PATH]
Definition: filetypes.cpp:895
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:833
#define MB_ICONERROR
Definition: winuser.h:790
HWND WINAPI SetFocus(_In_opt_ HWND)
#define EM_SETSEL
Definition: winuser.h:2021
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by EditActionDlgProc().

◆ EditActionDlgProc()

static INT_PTR CALLBACK EditActionDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1049 of file filetypes.cpp.

1050{
1051 static PACTION_DIALOG s_pEditAct = NULL;
1052
1053 switch (uMsg)
1054 {
1055 case WM_INITDIALOG:
1056 s_pEditAct = (PACTION_DIALOG)lParam;
1057 s_pEditAct->bUseDDE = FALSE;
1058 SetDlgItemTextW(hwndDlg, IDC_ACTION_ACTION, s_pEditAct->szAction);
1059 SetDlgItemTextW(hwndDlg, IDC_ACTION_APP, s_pEditAct->szApp);
1062 {
1063 // set title
1065 str += GetTypeName(s_pEditAct->pEntry, s_pEditAct->pG);
1066 SetWindowTextW(hwndDlg, str);
1067 }
1068 return TRUE;
1069
1070 case WM_COMMAND:
1071 switch (LOWORD(wParam))
1072 {
1073 case IDOK:
1074 EditActionDlg_OnOK(hwndDlg, s_pEditAct);
1075 break;
1076
1077 case IDCANCEL:
1078 EndDialog(hwndDlg, IDCANCEL);
1079 break;
1080
1081 case IDC_ACTION_BROWSE:
1082 ActionDlg_OnBrowse(hwndDlg, s_pEditAct, TRUE);
1083 break;
1084 }
1085 break;
1086 }
1087 return 0;
1088}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
static LPWSTR GetTypeName(PFILE_TYPE_ENTRY Entry, PFILE_TYPE_GLOBALS pG)
Definition: filetypes.cpp:287
static void EditActionDlg_OnOK(HWND hwndDlg, PACTION_DIALOG pEditAct)
Definition: filetypes.cpp:1014
struct ACTION_DIALOG * PACTION_DIALOG
static void ActionDlg_OnBrowse(HWND hwndDlg, PACTION_DIALOG pNewAct, BOOL bEdit=FALSE)
Definition: filetypes.cpp:900
#define LOWORD(l)
Definition: pedump.c:82
#define IDC_ACTION_BROWSE
Definition: shresdef.h:500
#define IDC_ACTION_USE_DDE
Definition: shresdef.h:501
#define IDS_EDITING_ACTION
Definition: shresdef.h:336
PFILE_TYPE_GLOBALS pG
Definition: filetypes.cpp:892
PFILE_TYPE_ENTRY pEntry
Definition: filetypes.cpp:893
#define IDCANCEL
Definition: winuser.h:834
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by EditTypeDlg_OnCommand().

◆ EditTypeDlg_OnChangeIcon()

static void EditTypeDlg_OnChangeIcon ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 374 of file filetypes.cpp.

375{
377 INT IconIndex = pEditType->nIconIndex;
379 if (PickIconDlg(hwndDlg, szPath, _countof(szPath), &IconIndex))
380 {
381 HICON hIconLarge = DoExtractIcon(szPath, IconIndex, FALSE);
382
383 // replace Windows directory with "%SystemRoot%" (for portability)
384 WCHAR szWinDir[MAX_PATH];
385 UINT lenWinDir = GetWindowsDirectoryW(szWinDir, _countof(szWinDir));
386 if (StrStrIW(szPath, szWinDir) == szPath)
387 {
388 CPathW str(L"%SystemRoot%");
389 str.Append(&szPath[lenWinDir]);
390 StringCbCopyW(szPath, sizeof(szPath), str);
391 }
392
393 // update EDITTYPE_DIALOG
394 StringCbCopyW(pEditType->szIconPath, sizeof(pEditType->szIconPath), szPath);
395 pEditType->nIconIndex = IconIndex;
396 pEditType->ChangedIcon = true;
397
398 // set icon to dialog
399 HICON hOld = (HICON)SendDlgItemMessageW(hwndDlg, IDC_EDITTYPE_ICON, STM_SETICON, (WPARAM)hIconLarge, 0);
400 if (hOld)
401 DestroyIcon(hOld);
402 }
403}
LPWSTR WINAPI StrStrIW(LPCWSTR lpszStr, LPCWSTR lpszSearch)
Definition: string.c:380
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
static const WCHAR IconIndex[]
Definition: install.c:52
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:362
LPCWSTR szPath
Definition: env.c:37
static HICON
Definition: imagelist.c:80
#define IDC_EDITTYPE_ICON
Definition: shresdef.h:485
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
WCHAR szIconPath[MAX_PATH]
Definition: filetypes.cpp:366
int32_t INT
Definition: typedefs.h:58
UINT_PTR WPARAM
Definition: windef.h:207
#define STM_SETICON
Definition: winuser.h:2095
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2105

Referenced by EditTypeDlg_OnCommand().

◆ EditTypeDlg_OnCommand()

static void EditTypeDlg_OnCommand ( HWND  hwndDlg,
UINT  id,
UINT  code,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 1444 of file filetypes.cpp.

1445{
1446 INT iItem, iIndex;
1448 switch (id)
1449 {
1450 case IDOK:
1451 EditTypeDlg_OnOK(hwndDlg, pEditType);
1452 break;
1453
1454 case IDCANCEL:
1455 EndDialog(hwndDlg, IDCANCEL);
1456 break;
1457
1459 EditTypeDlg_OnChangeIcon(hwndDlg, pEditType);
1460 break;
1461
1462 case IDC_EDITTYPE_NEW:
1463 // open 'New Action' dialog
1464 action.bUseDDE = FALSE;
1465 action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1466 action.pEntry = pEditType->pEntry;
1469 {
1470 if (SendMessageW(action.hwndLB, LB_FINDSTRING, -1, (LPARAM)action.szAction) != LB_ERR)
1471 {
1472 // already exists, error
1473 HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_ACTION);
1474 SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
1475 SetFocus(hwndCtrl);
1476
1477 CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_FILE_TYPES));
1478 strText.Format(IDS_ACTION_EXISTS, action.szAction);
1479 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
1480 }
1481 else
1482 {
1483 // add it
1484 CStringW strCommandLine = action.szApp;
1485 QuoteAppPathForCommand(strCommandLine);
1486 strCommandLine += L" \"%1\"";
1487 pEditType->CommandLineMap.SetAt(action.szAction, strCommandLine);
1488 pEditType->ModifiedVerbs.AddHead(action.szAction);
1489 SendMessageW(action.hwndLB, LB_ADDSTRING, 0, LPARAM(action.szAction));
1490 if (SendMessageW(action.hwndLB, LB_GETCOUNT, 0, 0) == 1)
1491 {
1492 // set default
1493 StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), action.szAction);
1494 InvalidateRect(action.hwndLB, NULL, TRUE);
1495 }
1496 }
1497 }
1498 break;
1499
1501 if (code == LBN_SELCHANGE)
1502 {
1503 action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1504 INT iItem = SendMessageW(action.hwndLB, LB_GETCURSEL, 0, 0);
1505 SendMessageW(action.hwndLB, LB_GETTEXT, iItem, LPARAM(action.szAction));
1506 if (lstrcmpiW(action.szAction, pEditType->szDefaultVerb) == 0)
1507 {
1509 }
1510 else
1511 {
1513 }
1514 EditTypeDlg_Restrict(hwndDlg, pEditType);
1515 break;
1516 }
1517 else if (code != LBN_DBLCLK)
1518 {
1519 break;
1520 }
1521 // FALL THROUGH
1522
1524 action.bUseDDE = FALSE;
1525 action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1526 action.pG = pEditType->pG;
1527 action.pEntry = pEditType->pEntry;
1528 iItem = SendMessageW(action.hwndLB, LB_GETCURSEL, 0, 0);
1529 if (iItem == LB_ERR)
1530 break;
1531
1532 // get action
1533 SendMessageW(action.hwndLB, LB_GETTEXT, iItem, LPARAM(action.szAction));
1534
1535 // get app
1536 {
1537 iIndex = pEditType->CommandLineMap.FindKey(action.szAction);
1538 CStringW str = pEditType->CommandLineMap.GetValueAt(iIndex);
1539 StringCbCopyW(action.szApp, sizeof(action.szApp), LPCWSTR(str));
1540 }
1541
1542 // open dialog
1545 {
1546 SendMessageW(action.hwndLB, LB_DELETESTRING, iItem, 0);
1547 SendMessageW(action.hwndLB, LB_INSERTSTRING, iItem, LPARAM(action.szAction));
1548 pEditType->CommandLineMap.SetAt(action.szAction, action.szApp);
1549 pEditType->ModifiedVerbs.AddHead(action.szAction);
1550 }
1551 break;
1552
1554 EditTypeDlg_OnRemove(hwndDlg, pEditType);
1555 break;
1556
1558 action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1559 iItem = SendMessageW(action.hwndLB, LB_GETCURSEL, 0, 0);
1560 if (iItem == LB_ERR)
1561 break;
1562
1563 SendMessageW(action.hwndLB, LB_GETTEXT, iItem, LPARAM(action.szAction));
1564
1565 // set default
1566 StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), action.szAction);
1568 InvalidateRect(action.hwndLB, NULL, TRUE);
1569 break;
1570 }
1571}
POSITION AddHead(INARGTYPE element)
Definition: atlcoll.h:612
TVal & GetValueAt(int nIndex)
Definition: atlsimpcoll.h:358
BOOL SetAt(const TKey &key, const TVal &val)
Definition: atlsimpcoll.h:402
int FindKey(const TKey &key) const
Definition: atlsimpcoll.h:315
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
const WCHAR * action
Definition: action.c:7509
static INT_PTR CALLBACK NewActionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:978
static BOOL EditTypeDlg_OnRemove(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1418
static void EditTypeDlg_OnChangeIcon(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:374
static void EditTypeDlg_Restrict(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1094
static INT_PTR CALLBACK EditActionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:1049
static void EditTypeDlg_OnOK(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1386
#define IDD_ACTION
Definition: shresdef.h:524
#define IDC_EDITTYPE_SET_DEFAULT
Definition: shresdef.h:492
#define IDC_EDITTYPE_EDIT_BUTTON
Definition: shresdef.h:490
#define IDC_EDITTYPE_LISTBOX
Definition: shresdef.h:488
#define IDS_ACTION_EXISTS
Definition: shresdef.h:334
#define IDC_EDITTYPE_NEW
Definition: shresdef.h:489
#define IDC_EDITTYPE_CHANGE_ICON
Definition: shresdef.h:487
#define IDC_EDITTYPE_REMOVE
Definition: shresdef.h:491
CSimpleMap< CStringW, CStringW > CommandLineMap
Definition: filetypes.cpp:364
CAtlList< CStringW > ModifiedVerbs
Definition: filetypes.cpp:365
WCHAR szDefaultVerb[VERBKEY_CCHMAX]
Definition: filetypes.cpp:369
PFILE_TYPE_GLOBALS pG
Definition: filetypes.cpp:362
PFILE_TYPE_ENTRY pEntry
Definition: filetypes.cpp:363
Definition: inflate.c:139
LONG_PTR LPARAM
Definition: windef.h:208
#define LB_ERR
Definition: winuser.h:2435
#define LB_GETCOUNT
Definition: winuser.h:2041
#define LB_GETTEXT
Definition: winuser.h:2052
#define LBN_DBLCLK
Definition: winuser.h:2074
#define LB_ADDSTRING
Definition: winuser.h:2034
#define LB_DELETESTRING
Definition: winuser.h:2035
#define LB_FINDSTRING
Definition: winuser.h:2037
#define LB_INSERTSTRING
Definition: winuser.h:2056
#define LBN_SELCHANGE
Definition: winuser.h:2078
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define LB_GETCURSEL
Definition: winuser.h:2042
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by EditTypeDlgProc().

◆ EditTypeDlg_OnDrawItem()

static BOOL EditTypeDlg_OnDrawItem ( HWND  hwndDlg,
LPDRAWITEMSTRUCT  pDraw,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 406 of file filetypes.cpp.

407{
408 WCHAR szText[MAX_PATH];
409 HFONT hFont, hFont2;
410
411 if (!pDraw)
412 return FALSE;
413
414 // fill rect and set colors
415 if (pDraw->itemState & ODS_SELECTED)
416 {
417 FillRect(pDraw->hDC, &pDraw->rcItem, HBRUSH(COLOR_HIGHLIGHT + 1));
420 }
421 else
422 {
423 FillRect(pDraw->hDC, &pDraw->rcItem, HBRUSH(COLOR_WINDOW + 1));
426 }
427
428 // get listbox text
429 HWND hwndListBox = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
430 SendMessageW(hwndListBox, LB_GETTEXT, pDraw->itemID, (LPARAM)szText);
431
432 // is it default?
433 hFont = (HFONT)SendMessageW(hwndListBox, WM_GETFONT, 0, 0);
434 if (lstrcmpiW(pEditType->szDefaultVerb, szText) == 0)
435 {
436 // default. set bold
437 LOGFONTW lf;
438 GetObject(hFont, sizeof(lf), &lf);
439 lf.lfWeight = FW_BOLD;
440 hFont2 = CreateFontIndirectW(&lf);
441 if (hFont2)
442 {
443 HGDIOBJ hFontOld = SelectObject(pDraw->hDC, hFont2);
445 DrawTextW(pDraw->hDC, szText, -1, &pDraw->rcItem,
448 SelectObject(pDraw->hDC, hFontOld);
449 DeleteObject(hFont2);
450 }
451 }
452 else
453 {
454 // non-default
456 DrawTextW(pDraw->hDC, szText, -1, &pDraw->rcItem,
459 }
460
461 // draw focus rect
462 if (pDraw->itemState & ODS_FOCUS)
463 {
464 DrawFocusRect(pDraw->hDC, &pDraw->rcItem);
465 }
466 return TRUE;
467}
HFONT hFont
Definition: main.c:53
#define LISTBOX_MARGIN
Definition: filetypes.cpp:355
pKey DeleteObject()
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
LONG lfWeight
Definition: dimm.idl:63
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
#define FW_BOLD
Definition: wingdi.h:378
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
#define GetObject
Definition: wingdi.h:4468
DWORD WINAPI GetSysColor(_In_ int)
#define ODS_SELECTED
Definition: winuser.h:2548
#define DT_NOPREFIX
Definition: winuser.h:537
#define COLOR_WINDOW
Definition: winuser.h:921
#define COLOR_WINDOWTEXT
Definition: winuser.h:924
#define COLOR_HIGHLIGHT
Definition: winuser.h:929
#define DT_SINGLELINE
Definition: winuser.h:540
#define WM_GETFONT
Definition: winuser.h:1654
#define DT_LEFT
Definition: winuser.h:534
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:930
#define DT_VCENTER
Definition: winuser.h:543
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define ODS_FOCUS
Definition: winuser.h:2552

Referenced by EditTypeDlgProc().

◆ EditTypeDlg_OnInitDialog()

static BOOL EditTypeDlg_OnInitDialog ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 1574 of file filetypes.cpp.

1575{
1576 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1577 EDITTYPEFLAGS Etf;
1578 ExpandEnvironmentStringsW(pEntry->IconPath, pEditType->szIconPath, _countof(pEditType->szIconPath));
1579 pEditType->nIconIndex = pEntry->nIconIndex;
1580 StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), L"open");
1581 pEditType->ChangedIcon = false;
1582
1583 // set info
1584 HICON hIco = DoExtractIcon(pEditType->szIconPath, pEditType->nIconIndex);
1586 EditTypeDlg_ReadClass(hwndDlg, pEditType, Etf);
1589 EnableWindow(GetDlgItem(hwndDlg, IDC_EDITTYPE_SHOW_EXT), pEntry->IsExtension());
1592
1593 // select first item
1595 // is listbox empty?
1596 if (SendDlgItemMessageW(hwndDlg, IDC_EDITTYPE_LISTBOX, LB_GETCOUNT, 0, 0) == 0)
1597 {
1601 }
1602 EditTypeDlg_Restrict(hwndDlg, pEditType);
1603 return TRUE;
1604}
static BOOL EditTypeDlg_ReadClass(HWND hwndDlg, PEDITTYPE_DIALOG pEditType, EDITTYPEFLAGS &Etf)
Definition: filetypes.cpp:1301
EDITTYPEFLAGS
Definition: filetypes.cpp:357
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
@ FTA_OpenIsSafe
Definition: shlwapi.h:665
#define IDC_EDITTYPE_CONFIRM_OPEN
Definition: shresdef.h:493
#define IDC_EDITTYPE_SHOW_EXT
Definition: shresdef.h:494
#define IDC_EDITTYPE_SAME_WINDOW
Definition: shresdef.h:495
Definition: filetypes.cpp:42
#define BM_SETCHECK
Definition: winuser.h:1924
#define LB_SETCURSEL
Definition: winuser.h:2066

Referenced by EditTypeDlgProc().

◆ EditTypeDlg_OnMeasureItem()

static BOOL EditTypeDlg_OnMeasureItem ( HWND  hwndDlg,
LPMEASUREITEMSTRUCT  pMeasure,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 470 of file filetypes.cpp.

471{
472 if (!pMeasure)
473 return FALSE;
474
475 HWND hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
476
477 HDC hDC = GetDC(hwndLB);
478 if (hDC)
479 {
482 pMeasure->itemHeight = tm.tmHeight + LISTBOX_MARGIN * 2;
483 ReleaseDC(hwndLB, hDC);
484 return TRUE;
485 }
486 return FALSE;
487}
static HDC hDC
Definition: 3dtext.c:33
static HDC
Definition: imagelist.c:88
Definition: time.h:68
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by EditTypeDlgProc().

◆ EditTypeDlg_OnOK()

static void EditTypeDlg_OnOK ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 1386 of file filetypes.cpp.

1387{
1388 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1389
1390 WCHAR TypeName[TYPENAME_CCHMAX];
1391 GetDlgItemTextW(hwndDlg, IDC_EDITTYPE_TEXT, TypeName, _countof(TypeName));
1392 StrTrimW(TypeName, g_pszSpace);
1393
1394 UINT etf = 0;
1395 pEntry->EditFlags &= ~(FTA_MODIFYMASK);
1397 pEntry->EditFlags |= FTA_OpenIsSafe;
1399 etf |= ETF_ALWAYSEXT;
1401 etf |= ETF_BROWSESAME;
1402
1403 // update entry icon
1404 EditTypeDlg_UpdateEntryIcon(hwndDlg, pEditType);
1405
1406 // write registry
1407 EditTypeDlg_WriteClass(hwndDlg, pEditType, TypeName, (EDITTYPEFLAGS)etf);
1408
1409 pEntry->InvalidateDefaultApp();
1410
1411 // update the icon cache
1413
1414 EndDialog(hwndDlg, IDOK);
1415}
static BOOL EditTypeDlg_UpdateEntryIcon(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1113
static BOOL EditTypeDlg_WriteClass(HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR TypeName, EDITTYPEFLAGS Etf)
Definition: filetypes.cpp:1150
#define TYPENAME_CCHMAX
Definition: filetypes.cpp:38
#define FTA_MODIFYMASK
Definition: filetypes.cpp:33
if(dx< 0)
Definition: linetemp.h:194
#define IDC_EDITTYPE_TEXT
Definition: shresdef.h:486
#define BM_GETCHECK
Definition: winuser.h:1921

Referenced by EditTypeDlg_OnCommand().

◆ EditTypeDlg_OnRemove()

static BOOL EditTypeDlg_OnRemove ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 1418 of file filetypes.cpp.

1419{
1420 // get current selection
1422 if (iItem == LB_ERR)
1423 return FALSE;
1424
1425 // ask user for removal
1428 if (MessageBoxW(hwndDlg, strText, strTitle, MB_ICONINFORMATION | MB_YESNO) == IDNO)
1429 return FALSE;
1430
1431 // get text
1432 WCHAR szText[VERBKEY_CCHMAX];
1433 szText[0] = 0;
1434 SendDlgItemMessageW(hwndDlg, IDC_EDITTYPE_LISTBOX, LB_GETTEXT, iItem, (LPARAM)szText);
1435 StrTrimW(szText, g_pszSpace);
1436
1437 // remove it
1438 pEditType->CommandLineMap.Remove(szText);
1440 return TRUE;
1441}
BOOL Remove(const TKey &key)
Definition: atlsimpcoll.h:378
#define VERBKEY_CCHMAX
Definition: precomp.h:129
#define IDS_REMOVE_ACTION
Definition: shresdef.h:333
#define MB_YESNO
Definition: winuser.h:820
#define IDNO
Definition: winuser.h:839
#define MB_ICONINFORMATION
Definition: winuser.h:805

Referenced by EditTypeDlg_OnCommand().

◆ EditTypeDlg_ReadClass()

static BOOL EditTypeDlg_ReadClass ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType,
EDITTYPEFLAGS Etf 
)
static

Definition at line 1301 of file filetypes.cpp.

1302{
1303 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1304 LPCWSTR ClassKey;
1305 HRESULT hr = GetClassKey(*pEntry, ClassKey);
1307 if (FAILED(hr) || RegOpenKeyExW(HKEY_CLASSES_ROOT, ClassKey, 0, KEY_READ, &hClassKey))
1308 return FALSE;
1309
1310 UINT etfbits = (RegValueExists(hClassKey, L"AlwaysShowExt")) ? ETF_ALWAYSEXT : 0;
1311
1312 // 8 in BrowserFlags listed in KB 162059 seems to be our bit
1313 BOOL docobj = RegKeyExists(hClassKey, L"DocObject");
1315 etfbits |= (docobj && (GetRegDWORD(hClassKey, L"BrowserFlags") & 8)) ? 0 : ETF_BROWSESAME;
1316
1317 Etf = EDITTYPEFLAGS(etfbits);
1318
1319 // open "shell" key
1320 HKEY hShellKey;
1321 if (RegOpenKeyExW(hClassKey, L"shell", 0, KEY_READ, &hShellKey) != ERROR_SUCCESS)
1322 {
1324 return FALSE;
1325 }
1326
1327 WCHAR DefaultVerb[VERBKEY_CCHMAX];
1328 DWORD dwSize = sizeof(DefaultVerb);
1329 if (RegQueryValueExW(hShellKey, NULL, NULL, NULL,
1330 LPBYTE(DefaultVerb), &dwSize) == ERROR_SUCCESS)
1331 {
1332 StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), DefaultVerb);
1333 }
1334 else
1335 {
1336 StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), L"open");
1337 }
1338
1339 // enumerate shell verbs
1340 WCHAR szVerbName[VERBKEY_CCHMAX];
1341 DWORD dwIndex = 0;
1342 while (RegEnumKeyW(hShellKey, dwIndex, szVerbName, _countof(szVerbName)) == ERROR_SUCCESS)
1343 {
1344 // open verb key
1345 HKEY hVerbKey;
1346 LONG nResult = RegOpenKeyExW(hShellKey, szVerbName, 0, KEY_READ, &hVerbKey);
1347 if (nResult == ERROR_SUCCESS)
1348 {
1349 // open command key
1350 HKEY hCommandKey;
1351 nResult = RegOpenKeyExW(hVerbKey, L"command", 0, KEY_READ, &hCommandKey);
1352 if (nResult == ERROR_SUCCESS)
1353 {
1354 // get command line
1355 WCHAR szValue[MAX_PATH * 2];
1356 dwSize = sizeof(szValue);
1357 nResult = RegQueryValueExW(hCommandKey, NULL, NULL, NULL, LPBYTE(szValue), &dwSize);
1358 if (nResult == ERROR_SUCCESS)
1359 {
1360 pEditType->CommandLineMap.SetAt(szVerbName, szValue);
1361 }
1362
1363 RegCloseKey(hCommandKey);
1364 }
1365
1366 RegCloseKey(hVerbKey);
1367 }
1369 ++dwIndex;
1370 }
1371
1372 WCHAR TypeName[TYPENAME_CCHMAX];
1373 dwSize = sizeof(TypeName);
1374 if (!RegQueryValueExW(hClassKey, NULL, NULL, NULL, LPBYTE(TypeName), &dwSize))
1375 {
1376 TypeName[_countof(TypeName) - 1] = UNICODE_NULL; // Terminate
1377 SetDlgItemTextW(hwndDlg, IDC_EDITTYPE_TEXT, TypeName);
1378 }
1379
1380 RegCloseKey(hShellKey);
1382 return TRUE;
1383}
HKEY hClassKey
Definition: umpnpmgr.c:45
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2393
BOOL RegKeyExists(HKEY hKey, LPCWSTR Path)
Definition: utils.h:17
BOOL RegValueExists(HKEY hKey, LPCWSTR Name)
Definition: utils.h:11
static HRESULT GetClassKey(const FILE_TYPE_ENTRY &FTE, LPCWSTR &SubKey)
Definition: filetypes.cpp:123
static DWORD GetRegDWORD(HKEY hKey, LPCWSTR Name, DWORD &Value, DWORD DefaultValue=0, BOOL Strict=FALSE)
Definition: filetypes.cpp:98
#define FAILED(hr)
Definition: intsafe.h:51
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
long LONG
Definition: pedump.c:60
HRESULT hr
Definition: shlfolder.c:183

Referenced by EditTypeDlg_OnInitDialog().

◆ EditTypeDlg_Restrict()

static void EditTypeDlg_Restrict ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 1094 of file filetypes.cpp.

1095{
1096 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1097 static const WORD map[] = {
1104 };
1105 for (SIZE_T i = 0; i < _countof(map); i += 2)
1106 {
1107 if (pEntry->EditFlags & map[i + 0])
1108 EnableWindow(GetDlgItem(hwndDlg, map[i + 1]), FALSE);
1109 }
1110}
Definition: _map.h:48
unsigned short WORD
Definition: ntddk_ex.h:93
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
@ FTA_NoEditDflt
Definition: shlwapi.h:660
@ FTA_NoEditDesc
Definition: shlwapi.h:658
@ FTA_NoEditVerb
Definition: shlwapi.h:656
@ FTA_NoRemoveVerb
Definition: shlwapi.h:657
@ FTA_NoNewVerb
Definition: shlwapi.h:655
@ FTA_NoEditIcon
Definition: shlwapi.h:659
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by EditTypeDlg_OnCommand(), and EditTypeDlg_OnInitDialog().

◆ EditTypeDlg_UpdateEntryIcon()

static BOOL EditTypeDlg_UpdateEntryIcon ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 1113 of file filetypes.cpp.

1114{
1115 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1117
1118 pEntry->IconPath[0] = UNICODE_NULL; // I want the default icon
1120 pEntry->DestroyIcons();
1121 pEntry->hIconSmall = DoExtractIcon(pEntry->IconPath, pEntry->nIconIndex, TRUE);
1122 if (ExpandEnvironmentStringsW(pEditType->szIconPath, buf, _countof(buf)) && buf[0])
1123 {
1124 HICON hIco = DoExtractIcon(buf, pEditType->nIconIndex, TRUE);
1125 if (hIco)
1126 {
1127 pEntry->DestroyIcons();
1128 pEntry->hIconSmall = hIco;
1129 }
1130 }
1131 StringCbCopyW(pEntry->IconPath, sizeof(pEntry->IconPath), pEditType->szIconPath);
1132 pEntry->nIconIndex = pEditType->nIconIndex;
1133
1134 HWND hListView = pEditType->hwndLV;
1135 InitializeDefaultIcons(pEditType->pG);
1136 HIMAGELIST himlSmall = pEditType->pG->himlSmall;
1137 INT iSmallImage = ImageList_AddIcon(himlSmall, pEntry->hIconSmall);
1138
1139 INT iItem = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
1140 if (iItem != -1)
1141 {
1142 LV_ITEMW Item = { LVIF_IMAGE, iItem };
1143 Item.iImage = iSmallImage;
1144 ListView_SetItem(hListView, &Item);
1145 }
1146 return TRUE;
1147}
static BOOL Normalize(PFILE_TYPE_ENTRY Entry)
Definition: filetypes.cpp:341
static void InitializeDefaultIcons(PFILE_TYPE_GLOBALS pG)
Definition: filetypes.cpp:324
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define LVNI_SELECTED
Definition: commctrl.h:2429
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2439
#define ListView_SetItem(hwnd, pitem)
Definition: commctrl.h:2406
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define LV_ITEMW
Definition: commctrl.h:2337
#define LVIF_IMAGE
Definition: commctrl.h:2315
HIMAGELIST himlSmall
Definition: filetypes.cpp:87
_In_ WDFCOLLECTION _In_ WDFOBJECT Item

Referenced by EditTypeDlg_OnOK().

◆ EditTypeDlg_WriteClass()

static BOOL EditTypeDlg_WriteClass ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType,
LPCWSTR  TypeName,
EDITTYPEFLAGS  Etf 
)
static

Definition at line 1150 of file filetypes.cpp.

1152{
1153 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1154 LPCWSTR ClassKey;
1155 HRESULT hr = GetClassKey(*pEntry, ClassKey);
1156 BOOL OnlyExt = hr != S_OK;
1158 if (FAILED(hr) || RegCreateKeyExW(HKEY_CLASSES_ROOT, ClassKey, 0, NULL, 0,
1161 {
1162 return FALSE;
1163 }
1164
1165 // Refresh the EditFlags
1166 DWORD dw;
1167 if (GetRegDWORD(hClassKey, L"EditFlags", dw, 0, FALSE) == ERROR_SUCCESS)
1168 pEntry->EditFlags = (dw & ~FTA_MODIFYMASK) | (pEntry->EditFlags & FTA_MODIFYMASK);
1169
1170 if (!OnlyExt)
1171 {
1172 // Set class properties
1173 RegSetOrDelete(hClassKey, L"EditFlags", REG_DWORD, pEntry->EditFlags ? &pEntry->EditFlags : NULL, 4);
1174 if (pEntry->IsExtension())
1175 {
1176 RegSetOrDelete(hClassKey, L"AlwaysShowExt", REG_SZ, (Etf & ETF_ALWAYSEXT) ? L"" : NULL, 0);
1177 }
1178 if (RegKeyExists(hClassKey, L"DocObject"))
1179 {
1180 LRESULT ec = GetRegDWORD(hClassKey, L"BrowserFlags", dw, 0, TRUE);
1181 if (ec == ERROR_SUCCESS || ec == ERROR_FILE_NOT_FOUND)
1182 {
1183 dw = (dw & ~8) | ((Etf & ETF_BROWSESAME) ? 0 : 8); // Note: 8 means NOT
1184 RegSetOrDelete(hClassKey, L"BrowserFlags", REG_DWORD, dw ? &dw : NULL, sizeof(dw));
1185 }
1186 }
1187 }
1188 if (!(pEntry->EditFlags & FTA_NoEditDesc))
1189 {
1190 if (!OnlyExt)
1191 RegDeleteValueW(hClassKey, NULL); // Legacy name (in ProgId only)
1192
1193 // Deleting this value is always the correct thing to do but Windows does not do this.
1194 // This means the user cannot override the translated known type names set by the OS.
1195 if (OnlyExt)
1196 RegDeleteValueW(hClassKey, L"FriendlyTypeName"); // MUI name (extension or ProgId)
1197
1198 if (TypeName[0])
1199 RegSetString(hClassKey, OnlyExt ? L"FriendlyTypeName" : NULL, TypeName, REG_SZ);
1200 pEntry->InvalidateTypeName();
1201 }
1202
1203 if (pEntry->IconPath[0] && !(pEntry->EditFlags & FTA_NoEditIcon) && pEditType->ChangedIcon)
1204 {
1205 HKEY hDefaultIconKey;
1206 if (RegCreateKeyExW(hClassKey, L"DefaultIcon", 0, NULL, 0, KEY_WRITE,
1207 NULL, &hDefaultIconKey, NULL) == ERROR_SUCCESS)
1208 {
1209 DWORD type = REG_SZ;
1211 LPCWSTR fmt = L"%s,%d";
1212 if (!lstrcmpW(pEntry->IconPath, L"%1"))
1213 {
1214 fmt = L"%s"; // No icon index for "%1"
1215 }
1216 else if (StrChrW(pEntry->IconPath, L'%'))
1217 {
1219 }
1220 StringCbPrintfW(buf, sizeof(buf), fmt, pEntry->IconPath, pEntry->nIconIndex);
1221
1222 RegSetString(hDefaultIconKey, NULL, buf, type);
1223 RegCloseKey(hDefaultIconKey);
1224 }
1225 }
1226
1227 HKEY hShellKey;
1228 if (RegCreateKeyExW(hClassKey, L"shell", 0, NULL, 0, KEY_READ | KEY_WRITE, NULL,
1229 &hShellKey, NULL) != ERROR_SUCCESS)
1230 {
1232 return FALSE;
1233 }
1234
1235 // set default action
1236 if (!(pEntry->EditFlags & FTA_NoEditDflt))
1237 {
1238 if (pEditType->szDefaultVerb[0])
1239 RegSetString(hShellKey, NULL, pEditType->szDefaultVerb, REG_SZ);
1240 else
1241 RegDeleteValueW(hShellKey, NULL);
1242 }
1243
1244 // delete shell commands
1245 WCHAR szVerbName[VERBKEY_CCHMAX];
1246 DWORD dwIndex = 0;
1247 while (RegEnumKeyW(hShellKey, dwIndex, szVerbName, _countof(szVerbName)) == ERROR_SUCCESS)
1248 {
1249 if (pEditType->CommandLineMap.FindKey(szVerbName) == -1)
1250 {
1251 // doesn't exist in CommandLineMap, then delete it
1252 if (SHDeleteKeyW(hShellKey, szVerbName) == ERROR_SUCCESS)
1253 {
1254 --dwIndex;
1255 }
1256 }
1257 ++dwIndex;
1258 }
1259
1260 // write shell commands
1261 const INT nCount = pEditType->CommandLineMap.GetSize();
1262 for (INT i = 0; i < nCount; ++i)
1263 {
1264 const CStringW& key = pEditType->CommandLineMap.GetKeyAt(i);
1265 const CStringW& cmd = pEditType->CommandLineMap.GetValueAt(i);
1266 if (!pEditType->ModifiedVerbs.Find(key))
1267 {
1268 ASSERT(RegKeyExists(hShellKey, key));
1269 continue;
1270 }
1271
1272 // create verb key
1273 HKEY hVerbKey;
1274 if (RegCreateKeyExW(hShellKey, key, 0, NULL, 0, KEY_WRITE, NULL,
1275 &hVerbKey, NULL) == ERROR_SUCCESS)
1276 {
1277 // create command key
1278 HKEY hCommandKey;
1279 if (RegCreateKeyExW(hVerbKey, L"command", 0, NULL, 0, KEY_WRITE, NULL,
1280 &hCommandKey, NULL) == ERROR_SUCCESS)
1281 {
1282 DWORD dwSize = (cmd.GetLength() + 1) * sizeof(WCHAR);
1283 DWORD dwType = REG_SZ;
1284 int exp;
1285 if ((exp = cmd.Find('%', 0)) >= 0 && cmd.Find('%', exp + 1) >= 0)
1286 dwType = REG_EXPAND_SZ;
1287 RegSetValueExW(hCommandKey, NULL, 0, dwType, LPBYTE(LPCWSTR(cmd)), dwSize);
1288 RegCloseKey(hCommandKey);
1289 }
1290
1291 RegCloseKey(hVerbKey);
1292 }
1293 }
1294
1295 RegCloseKey(hShellKey);
1297 return TRUE;
1298}
POSITION Find(INARGTYPE element, _In_opt_ POSITION posStartAfter=NULL) const
Definition: atlcoll.h:794
TKey & GetKeyAt(int nIndex)
Definition: atlsimpcoll.h:341
int GetSize() const
Definition: atlsimpcoll.h:353
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:464
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
DWORD RegSetString(HKEY hKey, LPCWSTR Name, LPCWSTR Str, DWORD Type=REG_SZ)
Definition: utils.h:35
DWORD RegSetOrDelete(HKEY hKey, LPCWSTR Name, DWORD Type, LPCVOID Data, DWORD Size)
Definition: utils.h:26
#define ICONLOCATION_CCHMAX
Definition: filetypes.cpp:39
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define S_OK
Definition: intsafe.h:52
#define REG_SZ
Definition: layer.c:22
#define ASSERT(a)
Definition: mode.c:44
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
DWORD exp
Definition: msg.c:16058
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define REG_DWORD
Definition: sdbapi.c:596
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
Definition: ftp_var.h:139
Definition: dsound.c:943
Definition: copy.c:22
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by EditTypeDlg_OnOK().

◆ EditTypeDlgProc()

static INT_PTR CALLBACK EditTypeDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1608 of file filetypes.cpp.

1609{
1610 static PEDITTYPE_DIALOG s_pEditType = NULL;
1611 LPDRAWITEMSTRUCT pDraw;
1612 LPMEASUREITEMSTRUCT pMeasure;
1613
1614 switch (uMsg)
1615 {
1616 case WM_INITDIALOG:
1617 s_pEditType = (PEDITTYPE_DIALOG)lParam;
1618 return EditTypeDlg_OnInitDialog(hwndDlg, s_pEditType);
1619
1620 case WM_DESTROY:
1621 {
1623 if (hOld)
1624 DestroyIcon(hOld);
1625 break;
1626 }
1627
1628 case WM_DRAWITEM:
1629 pDraw = LPDRAWITEMSTRUCT(lParam);
1630 return EditTypeDlg_OnDrawItem(hwndDlg, pDraw, s_pEditType);
1631
1632 case WM_MEASUREITEM:
1633 pMeasure = LPMEASUREITEMSTRUCT(lParam);
1634 return EditTypeDlg_OnMeasureItem(hwndDlg, pMeasure, s_pEditType);
1635
1636 case WM_COMMAND:
1637 EditTypeDlg_OnCommand(hwndDlg, LOWORD(wParam), HIWORD(wParam), s_pEditType);
1638 break;
1639 }
1640
1641 return 0;
1642}
struct EDITTYPE_DIALOG * PEDITTYPE_DIALOG
static BOOL EditTypeDlg_OnDrawItem(HWND hwndDlg, LPDRAWITEMSTRUCT pDraw, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:406
static BOOL EditTypeDlg_OnMeasureItem(HWND hwndDlg, LPMEASUREITEMSTRUCT pMeasure, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:470
static BOOL EditTypeDlg_OnInitDialog(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1574
static void EditTypeDlg_OnCommand(HWND hwndDlg, UINT id, UINT code, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1444
#define HIWORD(l)
Definition: typedefs.h:247
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
struct tagMEASUREITEMSTRUCT * LPMEASUREITEMSTRUCT
#define WM_DRAWITEM
Definition: winuser.h:1648
#define STM_GETICON
Definition: winuser.h:2093
#define WM_MEASUREITEM
Definition: winuser.h:1649
#define WM_DESTROY
Definition: winuser.h:1612

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_AddExt()

static BOOL FileTypesDlg_AddExt ( HWND  hwndDlg,
LPCWSTR  pszExt,
LPCWSTR  pszProgId,
PFILE_TYPE_GLOBALS  pG 
)
static

Definition at line 803 of file filetypes.cpp.

804{
805 DWORD dwValue = 1;
806 HKEY hKey;
807 WCHAR szKey[13]; // max. "ft4294967295" + "\0"
808 LONG nResult;
809
810 if (!*pszProgId)
811 {
812 pszProgId = szKey;
813 // Search the next "ft%06u" key name
814 do
815 {
816 StringCbPrintfW(szKey, sizeof(szKey), L"ft%06u", dwValue);
817
818 nResult = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hKey);
819 if (nResult != ERROR_SUCCESS)
820 break;
821
823 ++dwValue;
824 } while (dwValue != 0);
825
827
828 if (dwValue == 0)
829 return FALSE;
830
831 // Create new "ft%06u" key
832 nResult = RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
833 if (ERROR_SUCCESS != nResult)
834 return FALSE;
836 }
837
838 // Create the ".ext" key
839 WCHAR szExt[ASSOC_CCHMAX];
840 if (*pszExt == L'.') // The user is allowed to type the extension with or without the . in the new dialog!
841 ++pszExt;
842 StringCbPrintfW(szExt, sizeof(szExt), L".%s", pszExt);
843 _wcslwr(szExt);
844 nResult = RegCreateKeyEx(HKEY_CLASSES_ROOT, szExt, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
845 _wcsupr(szExt);
846 if (ERROR_SUCCESS != nResult)
847 return FALSE;
848
849 // Set the default value of ".ext" to "ft%06u"
850 RegSetString(hKey, NULL, pszProgId, REG_SZ);
851
853
854 // Insert an item to the listview
855 HWND hListView = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
856 INT iItem = ListView_GetItemCount(hListView);
857 if (!FileTypesDlg_InsertToLV(hListView, szExt, iItem, pG))
858 return FALSE;
859
860 ListView_SetItemState(hListView, iItem, -1, LVIS_FOCUSED | LVIS_SELECTED);
861 ListView_EnsureVisible(hListView, iItem, FALSE);
862 return TRUE;
863}
#define ASSOC_CCHMAX
Definition: filetypes.cpp:37
static PFILE_TYPE_ENTRY FileTypesDlg_InsertToLV(HWND hListView, LPCWSTR Assoc, INT iItem, PFILE_TYPE_GLOBALS pG)
Definition: filetypes.cpp:714
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2678
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2312
#define LVIS_SELECTED
Definition: commctrl.h:2324
#define LVIS_FOCUSED
Definition: commctrl.h:2323
#define ListView_EnsureVisible(hwndLV, i, fPartialOK)
Definition: commctrl.h:2524
_CRTIMP wchar_t *__cdecl _wcsupr(_Inout_z_ wchar_t *_String)
_CRTIMP wchar_t *__cdecl _wcslwr(_Inout_z_ wchar_t *_String)
#define IDC_FILETYPES_LISTVIEW
Definition: shresdef.h:443
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegCreateKeyEx
Definition: winreg.h:501

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_CompareItems()

static INT CALLBACK FileTypesDlg_CompareItems ( LPARAM  lParam1,
LPARAM  lParam2,
LPARAM  lParamSort 
)
static

Definition at line 1648 of file filetypes.cpp.

1649{
1650 PFILE_TYPE_GLOBALS pG = (PFILE_TYPE_GLOBALS)lParamSort;
1651 PFILE_TYPE_ENTRY entry1 = (PFILE_TYPE_ENTRY)lParam1, entry2 = (PFILE_TYPE_ENTRY)lParam2;
1652 int x = 0;
1653 if (pG->SortCol == 1)
1654 x = wcsicmp(GetTypeName(entry1, pG), GetTypeName(entry2, pG));
1655 if (!x && !(x = entry1->IsExtension() - entry2->IsExtension()))
1656 x = wcsicmp(entry1->FileExtension, entry2->FileExtension);
1657 return x * pG->SortReverse;
1658}
#define wcsicmp
Definition: compat.h:15
struct _FILE_TYPE_GLOBALS * PFILE_TYPE_GLOBALS
struct _FILE_TYPE_ENTRY * PFILE_TYPE_ENTRY
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
bool IsExtension() const
Definition: filetypes.cpp:53
WCHAR FileExtension[ASSOC_CCHMAX]
Definition: filetypes.cpp:43

Referenced by FileTypesDlg_Sort().

◆ FileTypesDlg_GetEntry()

static PFILE_TYPE_ENTRY FileTypesDlg_GetEntry ( HWND  hListView,
INT  iItem = -1 
)
inlinestatic

Definition at line 1791 of file filetypes.cpp.

1792{
1793 if (iItem == -1)
1794 {
1795 iItem = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
1796 if (iItem == -1)
1797 return NULL;
1798 }
1799
1800 LV_ITEMW lvItem = { LVIF_PARAM, iItem };
1801 if (ListView_GetItem(hListView, &lvItem))
1802 return (PFILE_TYPE_ENTRY)lvItem.lParam;
1803
1804 return NULL;
1805}
#define LVIF_PARAM
Definition: commctrl.h:2316
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2399

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_Initialize()

static PFILE_TYPE_GLOBALS FileTypesDlg_Initialize ( HWND  hwndDlg)
static

Definition at line 1755 of file filetypes.cpp.

1756{
1757 HWND hListView = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1759 if (!pG)
1760 return pG;
1761
1762 pG->SortReverse = 1;
1763 pG->hDefExtIconSmall = NULL;
1764 pG->hOpenWithImage = NULL;
1765 pG->IconSize = GetSystemMetrics(SM_CXSMICON); // Shell icons are always square
1766 pG->himlSmall = ImageList_Create(pG->IconSize, pG->IconSize, ILC_COLOR32 | ILC_MASK, 256, 20);
1767 pG->hHeap = GetProcessHeap();
1768
1769 pG->NoneString[0] = UNICODE_NULL;
1771
1773 {
1774 HKEY hKey;
1775 if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Classes", 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL))
1776 pG->Restricted = TRUE;
1777 else
1779 }
1780
1781 FileTypesDlg_InitListView(hwndDlg, hListView);
1784
1785 // Delay loading the items so the propertysheet has time to finalize the UI
1786 PostMessage(hListView, WM_KEYDOWN, VK_F5, 0);
1787 return pG;
1788}
#define IDS_NONE
Definition: resource.h:133
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define GetProcessHeap()
Definition: compat.h:736
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
static VOID FileTypesDlg_InitListView(HWND hwndDlg, HWND hListView)
Definition: filetypes.cpp:1669
#define LVSIL_SMALL
Definition: commctrl.h:2304
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2309
#define ILC_COLOR32
Definition: commctrl.h:358
#define ILC_MASK
Definition: commctrl.h:351
@ REST_NOFILEASSOCIATE
Definition: shlobj.h:1868
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:150
#define IDC_FILETYPES_NEW
Definition: shresdef.h:444
HBITMAP hOpenWithImage
Definition: filetypes.cpp:90
WCHAR NoneString[42]
Definition: filetypes.cpp:92
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define VK_F5
Definition: winuser.h:2262
#define PostMessage
Definition: winuser.h:5844
#define WM_KEYDOWN
Definition: winuser.h:1718

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_InitListView()

static VOID FileTypesDlg_InitListView ( HWND  hwndDlg,
HWND  hListView 
)
static

Definition at line 1669 of file filetypes.cpp.

1670{
1671 RECT clientRect;
1672 LPCWSTR columnName;
1673 WCHAR szBuf[50];
1674
1675 LVCOLUMNW col;
1677 col.fmt = 0;
1678
1679 GetClientRect(hListView, &clientRect);
1680 INT column0Size = (clientRect.right - clientRect.left) / 4;
1681
1682 columnName = L"Extensions"; // Default to English
1684 columnName = szBuf;
1685 col.pszText = const_cast<LPWSTR>(columnName);
1686 col.iSubItem = 0;
1687 col.cx = column0Size;
1688 SendMessageW(hListView, LVM_INSERTCOLUMNW, 0, (LPARAM)&col);
1689
1690 columnName = L"File Types"; // Default to English
1692 {
1693 columnName = szBuf;
1694 }
1695 else
1696 {
1697 ERR("Failed to load localized string!\n");
1698 }
1699 col.pszText = const_cast<LPWSTR>(columnName);
1700 col.iSubItem = 1;
1701 col.cx = clientRect.right - clientRect.left - column0Size - GetSystemMetrics(SM_CYVSCROLL);
1702 SendMessageW(hListView, LVM_INSERTCOLUMNW, 1, (LPARAM)&col);
1703
1704 const UINT lvexstyle = LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP;
1705 ListView_SetExtendedListViewStyleEx(hListView, lvexstyle, lvexstyle);
1706}
#define ERR(fmt,...)
Definition: precomp.h:57
#define ListView_SetExtendedListViewStyleEx(hwndLV, dwMask, dw)
Definition: commctrl.h:2731
#define LVS_EX_LABELTIP
Definition: commctrl.h:2748
#define LVCF_WIDTH
Definition: commctrl.h:2592
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2739
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2637
#define LVCF_FMT
Definition: commctrl.h:2591
#define LVCF_SUBITEM
Definition: commctrl.h:2594
#define LVCF_TEXT
Definition: commctrl.h:2593
#define IDS_COLUMN_EXTENSION
Definition: shresdef.h:142
LPWSTR pszText
Definition: commctrl.h:2572
LONG right
Definition: windef.h:308
LONG left
Definition: windef.h:306
#define SM_CYVSCROLL
Definition: winuser.h:984
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by FileTypesDlg_Initialize().

◆ FileTypesDlg_InsertToLV()

static PFILE_TYPE_ENTRY FileTypesDlg_InsertToLV ( HWND  hListView,
LPCWSTR  Assoc,
INT  iItem,
PFILE_TYPE_GLOBALS  pG 
)
static

Definition at line 714 of file filetypes.cpp.

715{
717 HKEY hKey, hTemp;
718 LVITEMW lvItem;
720
722 {
723 return NULL;
724 }
725 if (Assoc[0] != L'.' && !RegValueExists(hKey, L"URL Protocol"))
726 {
728 return NULL;
729 }
730
732 if (!Entry)
733 {
735 return NULL;
736 }
737 Entry->Initialize();
738
739 if (Assoc[0] == L'.')
740 {
741 if (PathIsExeW(Assoc))
742 {
743exclude:
744 HeapFree(pG->hHeap, 0, Entry);
746 return NULL;
747 }
748
749 dwSize = sizeof(Entry->ClassKey);
750 if (RegQueryValueExW(hKey, NULL, NULL, NULL, LPBYTE(Entry->ClassKey), &dwSize))
751 {
752 Entry->ClassKey[0] = UNICODE_NULL; // No ProgId
753 }
754#if SUPPORT_EXTENSIONWITHOUTPROGID
755 if (Entry->ClassKey[0] && !RegOpenKeyExW(HKEY_CLASSES_ROOT, Entry->ClassKey, 0, KEY_READ, &hTemp))
756 {
758 hKey = hTemp;
759 }
760#else
761 if (!Entry->ClassKey[0])
762 goto exclude;
763#endif
764 }
765
766 Entry->EditFlags = GetRegDWORD(hKey, L"EditFlags", 0);
767 if (Entry->EditFlags & FTA_Exclude)
768 goto exclude;
769
770 wcscpy(Entry->FileExtension, Assoc);
771
772 // get icon
773 Entry->IconPath[0] = UNICODE_NULL;
774 BOOL defaultIcon = !GetFileTypeIconsByKey(hKey, Entry, pG->IconSize);
775
777
778 // add icon to imagelist
779 INT iSmallImage = 0;
780 if (!defaultIcon && Entry->hIconSmall)
781 {
782 iSmallImage = ImageList_AddIcon(pG->himlSmall, Entry->hIconSmall);
783 }
784
785 lvItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
786 lvItem.iItem = iItem;
787 lvItem.iSubItem = 0;
788 lvItem.lParam = (LPARAM)Entry;
789 lvItem.iImage = iSmallImage;
790 lvItem.pszText = Assoc[0] == L'.' ? _wcsupr(&Entry->FileExtension[1]) : pG->NoneString;
791 SendMessageW(hListView, LVM_INSERTITEMW, 0, (LPARAM)&lvItem);
792
793 lvItem.mask = LVIF_TEXT;
794 lvItem.iItem = iItem;
795 lvItem.iSubItem = 1;
797 ListView_SetItem(hListView, &lvItem);
798
799 return Entry;
800}
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
EXTERN_C BOOL PathIsExeW(LPCWSTR lpszPath)
Definition: shellpath.c:539
static BOOL GetFileTypeIconsByKey(HKEY hKey, PFILE_TYPE_ENTRY Entry, UINT IconSize)
Definition: filetypes.cpp:220
#define LPSTR_TEXTCALLBACK
Definition: commctrl.h:2388
#define LVIF_TEXT
Definition: commctrl.h:2314
#define LVM_INSERTITEMW
Definition: commctrl.h:2409
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
@ FTA_Exclude
Definition: shlwapi.h:650
base of all file and directory entries
Definition: entries.h:83
LPWSTR pszText
Definition: commctrl.h:2370
int iSubItem
Definition: commctrl.h:2367
UINT mask
Definition: commctrl.h:2365
LPARAM lParam
Definition: commctrl.h:2373
int iImage
Definition: commctrl.h:2372

Referenced by FileTypesDlg_AddExt(), and FileTypesDlg_Refresh().

◆ FileTypesDlg_OnDelete()

static void FileTypesDlg_OnDelete ( HWND  hwndDlg)
static

Definition at line 1808 of file filetypes.cpp.

1809{
1812 if (MessageBoxW(hwndDlg, strRemoveExt, strTitle, MB_ICONQUESTION | MB_YESNO) == IDYES)
1813 {
1814 FileTypesDlg_RemoveExt(hwndDlg);
1815
1816 // Select first item (Win2k3 does it)
1817 HWND hListView = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1819 }
1820}
static BOOL FileTypesDlg_RemoveExt(HWND hwndDlg)
Definition: filetypes.cpp:866
#define IDS_REMOVE_EXT
Definition: shresdef.h:338
#define MB_ICONQUESTION
Definition: winuser.h:792
#define IDYES
Definition: winuser.h:838

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_OnItemChanging()

static void FileTypesDlg_OnItemChanging ( HWND  hwndDlg,
PFILE_TYPE_ENTRY  pEntry,
PFILE_TYPE_GLOBALS  pG 
)
static

Definition at line 1823 of file filetypes.cpp.

1824{
1825 HBITMAP &hbmProgram = pG->hOpenWithImage;
1826 LPCWSTR DispAssoc = pEntry->GetAssocForDisplay();
1827 LPCWSTR TypeName = GetTypeName(pEntry, pG);
1828 CStringW buf;
1829
1830 // format buffer and set description
1831 FileTypesDlg_SetGroupboxText(hwndDlg, DispAssoc);
1832 if (pEntry->IsExtension())
1833 buf.Format(IDS_FILE_DETAILSADV, DispAssoc, TypeName, TypeName);
1834 else
1835 buf = L"";
1836 SetDlgItemTextW(hwndDlg, IDC_FILETYPES_DESCRIPTION, buf.GetString());
1837
1838 // delete previous program image
1839 if (hbmProgram)
1840 {
1841 DeleteObject(hbmProgram);
1842 hbmProgram = NULL;
1843 }
1844
1845 // set program name
1846 LPCWSTR appname = GetAppName(pEntry);
1847 SetDlgItemTextW(hwndDlg, IDC_FILETYPES_APPNAME, appname);
1848
1849 // set program image
1850 HICON hIconSm = NULL;
1852 if (*exe)
1853 {
1854 ExtractIconExW(exe, 0, NULL, &hIconSm, 1);
1855 }
1856 hbmProgram = BitmapFromIcon(hIconSm, 16, 16);
1859
1860 // Enable/Disable the buttons
1862 !pG->Restricted && pEntry->IsExtension());
1864 !(pEntry->EditFlags & FTA_NoEdit) && !pG->Restricted);
1866 !(pEntry->EditFlags & FTA_NoRemove) && !pG->Restricted && pEntry->IsExtension());
1867}
static LPCWSTR GetAppName(PFILE_TYPE_ENTRY Entry)
Definition: filetypes.cpp:272
static void FileTypesDlg_SetGroupboxText(HWND hwndDlg, LPCWSTR Assoc)
Definition: filetypes.cpp:1709
static LPCWSTR GetProgramPath(PFILE_TYPE_ENTRY Entry)
Definition: filetypes.cpp:243
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:849
static HBITMAP BitmapFromIcon(HICON hIcon)
Definition: kbswitch.c:300
static HBITMAP
Definition: button.c:44
HICON hIconSm
Definition: msconfig.c:44
@ FTA_NoRemove
Definition: shlwapi.h:654
@ FTA_NoEdit
Definition: shlwapi.h:653
#define IDC_FILETYPES_DESCRIPTION
Definition: shresdef.h:449
#define IDC_FILETYPES_ICON
Definition: shresdef.h:451
#define IDC_FILETYPES_APPNAME
Definition: shresdef.h:447
#define IDC_FILETYPES_ADVANCED
Definition: shresdef.h:450
#define IDC_FILETYPES_DELETE
Definition: shresdef.h:445
#define IDC_FILETYPES_CHANGE
Definition: shresdef.h:448
#define IDS_FILE_DETAILSADV
Definition: shresdef.h:190
#define IMAGE_BITMAP
Definition: winuser.h:211
#define STM_SETIMAGE
Definition: winuser.h:2096

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_Refresh()

static void FileTypesDlg_Refresh ( HWND  hwndDlg,
HWND  hListView,
PFILE_TYPE_GLOBALS  pG 
)
static

Definition at line 1717 of file filetypes.cpp.

1718{
1719 ListView_DeleteAllItems(hListView);
1722 FileTypesDlg_SetGroupboxText(hwndDlg, L"");
1727#if DBG
1728 DWORD statTickStart = GetTickCount();
1729#endif
1730
1731 INT iItem = 0;
1733 DWORD dwName = _countof(szName);
1734 DWORD dwIndex = 0;
1735 SendMessage(hListView, WM_SETREDRAW, FALSE, 0);
1736 while (RegEnumKeyExW(HKEY_CLASSES_ROOT, dwIndex++, szName, &dwName,
1738 {
1739 if (FileTypesDlg_InsertToLV(hListView, szName, iItem, pG))
1740 ++iItem;
1741 dwName = _countof(szName);
1742 }
1743 FileTypesDlg_Sort(pG, hListView);
1744 SendMessage(hListView, WM_SETREDRAW, TRUE, 0);
1746
1747#if DBG
1748 DbgPrint("FT loaded %u (%ums)\n", iItem, GetTickCount() - statTickStart);
1749#endif
1750 // select first item
1752}
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:2504
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
static void FileTypesDlg_Sort(PFILE_TYPE_GLOBALS pG, HWND hListView, INT Column=-1)
Definition: filetypes.cpp:1661
#define DbgPrint
Definition: hal.h:12
static const WCHAR szName[]
Definition: powrprof.c:45
#define ImageList_RemoveAll(himl)
Definition: commctrl.h:556
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2419
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define RDW_UPDATENOW
Definition: winuser.h:1223
#define RDW_ERASE
Definition: winuser.h:1214
#define RDW_ALLCHILDREN
Definition: winuser.h:1224
#define RDW_FRAME
Definition: winuser.h:1215
#define SendMessage
Definition: winuser.h:5855
#define RDW_INVALIDATE
Definition: winuser.h:1217
#define WM_SETREDRAW
Definition: winuser.h:1619

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_RemoveExt()

static BOOL FileTypesDlg_RemoveExt ( HWND  hwndDlg)
static

Definition at line 866 of file filetypes.cpp.

867{
868 HWND hListView = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
869
870 INT iItem = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
871 if (iItem == -1)
872 return FALSE;
873
874 WCHAR szExt[MAX_PATH];
875 szExt[0] = L'.';
876 ListView_GetItemText(hListView, iItem, 0, &szExt[1], _countof(szExt) - 1);
877 _wcslwr(szExt);
878
879 if (DeleteExt(hwndDlg, szExt))
880 {
881 ListView_DeleteItem(hListView, iItem);
882 }
883 return TRUE;
884}
static BOOL DeleteExt(HWND hwndDlg, LPCWSTR pszExt)
Definition: filetypes.cpp:147
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2689
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2416

Referenced by FileTypesDlg_OnDelete().

◆ FileTypesDlg_SetGroupboxText()

static void FileTypesDlg_SetGroupboxText ( HWND  hwndDlg,
LPCWSTR  Assoc 
)
static

Definition at line 1709 of file filetypes.cpp.

1710{
1711 CStringW buf;
1712 buf.Format(IDS_FILE_DETAILS, Assoc);
1713 SetDlgItemTextW(hwndDlg, IDC_FILETYPES_DETAILS_GROUPBOX, buf.GetString());
1714}
#define IDS_FILE_DETAILS
Definition: shresdef.h:189
#define IDC_FILETYPES_DETAILS_GROUPBOX
Definition: shresdef.h:446

Referenced by FileTypesDlg_OnItemChanging(), and FileTypesDlg_Refresh().

◆ FileTypesDlg_Sort()

static void FileTypesDlg_Sort ( PFILE_TYPE_GLOBALS  pG,
HWND  hListView,
INT  Column = -1 
)
static

Definition at line 1661 of file filetypes.cpp.

1662{
1663 pG->SortReverse = pG->SortCol == Column ? pG->SortReverse * -1 : 1;
1664 pG->SortCol = Column < 0 ? 0 : (INT8) Column;
1666}
signed char INT8
static INT CALLBACK FileTypesDlg_CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: filetypes.cpp:1648
#define ListView_SortItems(hwndLV, _pfnCompare, _lPrm)
Definition: commctrl.h:2708

Referenced by FileTypesDlg_Refresh(), and FolderOptionsFileTypesDlg().

◆ FolderOptionsFileTypesDlg()

INT_PTR CALLBACK FolderOptionsFileTypesDlg ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1871 of file filetypes.cpp.

1876{
1878 if (!pGlobals && uMsg != WM_INITDIALOG)
1879 return FALSE;
1880 LPNMLISTVIEW lppl;
1882 NEWEXT_DIALOG newext;
1883 EDITTYPE_DIALOG edittype;
1884
1885 switch (uMsg)
1886 {
1887 case WM_INITDIALOG:
1890 return TRUE;
1891
1892 case WM_DESTROY:
1893 SetWindowLongPtrW(hwndDlg, DWLP_USER, 0);
1894 if (pGlobals)
1895 {
1896 DestroyIcon(pGlobals->hDefExtIconSmall);
1897 DeleteObject(pGlobals->hOpenWithImage);
1899 }
1900 break;
1901
1902 case WM_COMMAND:
1903 switch (LOWORD(wParam))
1904 {
1905 case IDC_FILETYPES_NEW:
1906 newext.hwndLV = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1908 hwndDlg, NewExtDlgProc, (LPARAM)&newext))
1909 {
1910 FileTypesDlg_AddExt(hwndDlg, newext.szExt, newext.szFileType, pGlobals);
1911 }
1912 break;
1913
1915 FileTypesDlg_OnDelete(hwndDlg);
1916 break;
1917
1920 if (pEntry)
1921 {
1922 OPENASINFO oai = { pEntry->FileExtension, 0, OAIF_FORCE_REGISTRATION | OAIF_REGISTER_EXT };
1923 if (SUCCEEDED(SHOpenWithDialog(hwndDlg, &oai)))
1924 {
1925 pEntry->InvalidateDefaultApp();
1927 }
1928 }
1929 break;
1930
1932 edittype.hwndLV = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1933 edittype.pG = pGlobals;
1934 edittype.pEntry = FileTypesDlg_GetEntry(edittype.hwndLV);
1935 if (Normalize(edittype.pEntry))
1936 {
1938 hwndDlg, EditTypeDlgProc, (LPARAM)&edittype);
1939 FileTypesDlg_OnItemChanging(hwndDlg, edittype.pEntry, pGlobals);
1940 }
1941 break;
1942 }
1943 break;
1944
1945 case WM_NOTIFY:
1946 lppl = (LPNMLISTVIEW) lParam;
1947 switch (lppl->hdr.code)
1948 {
1949 case LVN_GETDISPINFO:
1950 {
1953 if (entry && (pLVDI->item.mask & LVIF_TEXT))
1954 {
1955 if (pLVDI->item.iSubItem == 1)
1956 {
1958 pLVDI->item.mask |= LVIF_DI_SETITEM;
1959 }
1960 }
1961 break;
1962 }
1963
1964 case LVN_KEYDOWN:
1965 {
1966 LV_KEYDOWN *pKeyDown = (LV_KEYDOWN *)lParam;
1967 switch (pKeyDown->wVKey)
1968 {
1969 case VK_DELETE:
1970 FileTypesDlg_OnDelete(hwndDlg);
1971 break;
1972 case VK_F5:
1973 FileTypesDlg_Refresh(hwndDlg, pKeyDown->hdr.hwndFrom, pGlobals);
1974 break;
1975 }
1976 break;
1977 }
1978
1979 case NM_DBLCLK:
1981 break;
1982
1983 case LVN_DELETEALLITEMS:
1984 return FALSE; // send LVN_DELETEITEM
1985
1986 case LVN_DELETEITEM:
1988 if (pEntry)
1989 {
1990 pEntry->DestroyIcons();
1991 HeapFree(pGlobals->hHeap, 0, pEntry);
1992 }
1993 return FALSE;
1994
1995 case LVN_ITEMCHANGING:
1997 if (!pEntry)
1998 {
1999 return TRUE;
2000 }
2001
2002 if (!(lppl->uOldState & LVIS_FOCUSED) && (lppl->uNewState & LVIS_FOCUSED))
2003 {
2005 }
2006 break;
2007
2008 case LVN_COLUMNCLICK:
2010 break;
2011
2012 case PSN_SETACTIVE:
2013 // On page activation, set the focus to the listview
2015 break;
2016 }
2017 break;
2018 }
2019
2020 return FALSE;
2021}
HRESULT WINAPI SHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
static void FileTypesDlg_OnDelete(HWND hwndDlg)
Definition: filetypes.cpp:1808
static INT_PTR CALLBACK NewExtDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:677
static INT_PTR CALLBACK EditTypeDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:1608
static PFILE_TYPE_ENTRY FileTypesDlg_GetEntry(HWND hListView, INT iItem=-1)
Definition: filetypes.cpp:1791
static void FileTypesDlg_Refresh(HWND hwndDlg, HWND hListView, PFILE_TYPE_GLOBALS pG)
Definition: filetypes.cpp:1717
static void FileTypesDlg_OnItemChanging(HWND hwndDlg, PFILE_TYPE_ENTRY pEntry, PFILE_TYPE_GLOBALS pG)
Definition: filetypes.cpp:1823
static BOOL FileTypesDlg_AddExt(HWND hwndDlg, LPCWSTR pszExt, LPCWSTR pszProgId, PFILE_TYPE_GLOBALS pG)
Definition: filetypes.cpp:803
static PFILE_TYPE_GLOBALS FileTypesDlg_Initialize(HWND hwndDlg)
Definition: filetypes.cpp:1755
PFX_DRIVER_GLOBALS pGlobals
#define SUCCEEDED(hr)
Definition: intsafe.h:50
uint32_t entry
Definition: isohybrid.c:63
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define PSN_SETACTIVE
Definition: prsht.h:115
#define LVN_COLUMNCLICK
Definition: commctrl.h:3144
#define NM_DBLCLK
Definition: commctrl.h:131
#define LVN_DELETEALLITEMS
Definition: commctrl.h:3139
#define LVN_GETDISPINFO
Definition: commctrl.h:3165
#define LVN_ITEMCHANGING
Definition: commctrl.h:3135
struct tagNMLISTVIEW * LPNMLISTVIEW
struct tagLVDISPINFOW * LPNMLVDISPINFOW
#define LVN_KEYDOWN
Definition: commctrl.h:3189
#define LV_KEYDOWN
Definition: commctrl.h:3191
#define LVIF_DI_SETITEM
Definition: commctrl.h:3171
#define LVN_DELETEITEM
Definition: commctrl.h:3138
#define WM_NOTIFY
Definition: richedit.h:61
@ OAIF_REGISTER_EXT
Definition: shlobj.h:2681
@ OAIF_FORCE_REGISTRATION
Definition: shlobj.h:2683
#define IDD_NEWEXTENSION
Definition: shresdef.h:522
#define IDD_EDITTYPE
Definition: shresdef.h:523
LVITEMW item
Definition: commctrl.h:3184
UINT code
Definition: winuser.h:3162
HWND hwndFrom
Definition: winuser.h:3160
UINT uNewState
Definition: commctrl.h:3041
UINT uOldState
Definition: commctrl.h:3042
#define DWLP_USER
Definition: winuser.h:875
#define GetWindowLongPtrW
Definition: winuser.h:4832
#define VK_DELETE
Definition: winuser.h:2236
#define SetWindowLongPtrW
Definition: winuser.h:5358

Referenced by CFolderOptions::AddPages(), and ShowFolderOptionsDialogThreadProc().

◆ GetAppName()

static LPCWSTR GetAppName ( PFILE_TYPE_ENTRY  Entry)
static

Definition at line 272 of file filetypes.cpp.

273{
274 if (!Entry->AppName[1] && !Entry->AppName[0])
275 {
277 if (!*exe || !QueryFileDescription(exe, Entry->AppName, _countof(Entry->AppName)))
278 {
279 Entry->AppName[0] = UNICODE_NULL;
280 Entry->AppName[1] = TRUE;
281 }
282 }
283 return Entry->AppName;
284}
static BOOL QueryFileDescription(LPCWSTR ProgramPath, LPWSTR pszName, INT cchName)
Definition: filetypes.cpp:259

Referenced by FileTypesDlg_OnItemChanging().

◆ GetClassKey()

static HRESULT GetClassKey ( const FILE_TYPE_ENTRY FTE,
LPCWSTR SubKey 
)
static

Definition at line 123 of file filetypes.cpp.

124{
125 HRESULT hr = S_OK;
126 LPCWSTR path = FTE.IsExtension() ? FTE.ClassKey : FTE.FileExtension;
127#if SUPPORT_EXTENSIONWITHOUTPROGID
128 if (!*path && FTE.IsExtension())
129 {
130 path = FTE.FileExtension;
131 hr = S_FALSE;
132 }
133#endif
134 ASSERT(*path);
135 SubKey = path;
136 return hr;
137}
WCHAR ClassKey[MAX_PATH]
Definition: filetypes.cpp:45
#define S_FALSE
Definition: winerror.h:2357

Referenced by EditTypeDlg_ReadClass(), EditTypeDlg_WriteClass(), and GetTypeName().

◆ GetFileTypeIconsByKey()

static BOOL GetFileTypeIconsByKey ( HKEY  hKey,
PFILE_TYPE_ENTRY  Entry,
UINT  IconSize 
)
static

Definition at line 220 of file filetypes.cpp.

221{
222 Entry->hIconSmall = NULL;
223
224 HKEY hDefIconKey;
225 LONG nResult = RegOpenKeyExW(hKey, L"DefaultIcon", 0, KEY_READ, &hDefIconKey);
226 if (nResult != ERROR_SUCCESS)
227 return FALSE;
228
229 // Get the icon location
230 WCHAR szLocation[ICONLOCATION_CCHMAX];
231 DWORD dwSize = sizeof(szLocation);
232 nResult = RegQueryValueExW(hDefIconKey, NULL, NULL, NULL, LPBYTE(szLocation), &dwSize);
233 szLocation[_countof(szLocation) - 1] = UNICODE_NULL;
234
235 RegCloseKey(hDefIconKey);
236 if (nResult != ERROR_SUCCESS || !szLocation[0])
237 return FALSE;
238
239 return GetFileTypeIconsEx(Entry, szLocation, IconSize);
240}
static BOOL GetFileTypeIconsEx(PFILE_TYPE_ENTRY Entry, LPCWSTR IconLocation, UINT IconSize)
Definition: filetypes.cpp:192

Referenced by FileTypesDlg_InsertToLV().

◆ GetFileTypeIconsEx()

static BOOL GetFileTypeIconsEx ( PFILE_TYPE_ENTRY  Entry,
LPCWSTR  IconLocation,
UINT  IconSize 
)
static

Definition at line 192 of file filetypes.cpp.

193{
194 Entry->hIconSmall = NULL;
195 if (lstrcmpW(IconLocation, L"%1") == 0)
196 {
197 LPCWSTR ext = Entry->FileExtension;
198 if (!lstrcmpiW(ext, L".exe") || !lstrcmpiW(ext, L".scr"))
199 {
201 IMAGE_ICON, IconSize, IconSize, 0));
202 Entry->nIconIndex = -IDI_SHELL_EXE;
203 }
204 // Set the icon path to %1 on purpose so PickIconDlg will issue a warning
205 StringCbCopyW(Entry->IconPath, sizeof(Entry->IconPath), IconLocation);
206 }
207 else
208 {
209 // Expand the REG_EXPAND_SZ string by environment variables
210 if (ExpandEnvironmentStringsW(IconLocation, Entry->IconPath, _countof(Entry->IconPath)))
211 {
212 Entry->nIconIndex = PathParseIconLocationW(Entry->IconPath);
213 Entry->hIconSmall = DoExtractIcon(Entry->IconPath, Entry->nIconIndex, IconSize, IconSize);
214 }
215 }
216 return Entry->hIconSmall != NULL;
217}
static const WCHAR *const ext[]
Definition: module.c:53
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1092
#define IDI_SHELL_EXE
Definition: shresdef.h:555
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2255

Referenced by GetFileTypeIconsByKey().

◆ GetProgramPath()

static LPCWSTR GetProgramPath ( PFILE_TYPE_ENTRY  Entry)
static

Definition at line 243 of file filetypes.cpp.

244{
245 if (!Entry->ProgramPath[1] && !Entry->ProgramPath[0])
246 {
247 DWORD cch = _countof(Entry->ProgramPath);
249 Entry->FileExtension, NULL, Entry->ProgramPath, &cch)))
250 {
251 Entry->ProgramPath[0] = UNICODE_NULL;
252 Entry->ProgramPath[1] = TRUE;
253 }
254 }
255 return Entry->ProgramPath;
256}
HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
Definition: assoc.c:436
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
@ ASSOCSTR_EXECUTABLE
Definition: shlwapi.h:604
@ ASSOCF_INIT_IGNOREUNKNOWN
Definition: shlwapi.h:593

Referenced by FileTypesDlg_OnItemChanging(), and GetAppName().

◆ GetRegDWORD() [1/2]

static DWORD GetRegDWORD ( HKEY  hKey,
LPCWSTR  Name,
DWORD Value,
DWORD  DefaultValue = 0,
BOOL  Strict = FALSE 
)
static

Definition at line 98 of file filetypes.cpp.

99{
100 DWORD cb = sizeof(DWORD), type;
101 LRESULT ec = RegQueryValueExW(hKey, Name, 0, &type, (BYTE*)&Value, &cb);
102 if (ec == ERROR_SUCCESS)
103 {
104 if ((type == REG_DWORD && cb == sizeof(DWORD)) ||
105 (!Strict && type == REG_BINARY && (cb && cb <= sizeof(DWORD))))
106 {
107 Value &= (0xffffffffUL >> (32 - cb * 8));
108 return ec;
109 }
110 }
111 Value = DefaultValue;
112 return ec ? ec : ERROR_BAD_FORMAT;
113}
#define REG_BINARY
Definition: nt_native.h:1496
#define DWORD
Definition: nt_native.h:44
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define ERROR_BAD_FORMAT
Definition: winerror.h:114
unsigned char BYTE
Definition: xxhash.c:193

Referenced by EditTypeDlg_ReadClass(), EditTypeDlg_WriteClass(), FileTypesDlg_InsertToLV(), and GetRegDWORD().

◆ GetRegDWORD() [2/2]

static DWORD GetRegDWORD ( HKEY  hKey,
LPCWSTR  Name,
DWORD  DefaultValue = 0 
)
static

Definition at line 116 of file filetypes.cpp.

117{
118 GetRegDWORD(hKey, Name, DefaultValue, DefaultValue, FALSE);
119 return DefaultValue;
120}

◆ GetTypeName()

static LPWSTR GetTypeName ( PFILE_TYPE_ENTRY  Entry,
PFILE_TYPE_GLOBALS  pG 
)
static

Definition at line 287 of file filetypes.cpp.

288{
289 if (!Entry->FileDescription[1] && !Entry->FileDescription[0])
290 {
291 Entry->FileDescription[1] = TRUE;
292 if (Entry->IsExtension())
293 {
294 SHFILEINFOW fi;
295 if (SHGetFileInfoW(Entry->FileExtension, 0, &fi, sizeof(fi), SHGFI_TYPENAME |
297 {
298 StringCchCopyW(Entry->FileDescription, _countof(Entry->FileDescription), fi.szTypeName);
299 }
300 }
301 else
302 {
303 // FIXME: Fix and use ASSOCSTR_FRIENDLYDOCNAME
304 DWORD cb = sizeof(Entry->FileDescription), Fallback = TRUE;
305 LPCWSTR ClassKey;
306 HRESULT hr = GetClassKey(*Entry, ClassKey);
307 HKEY hKey;
308 if (SUCCEEDED(hr) && !RegOpenKeyExW(HKEY_CLASSES_ROOT, ClassKey, 0, KEY_READ, &hKey))
309 {
310 Fallback = RegQueryValueExW(hKey, NULL, 0, NULL, (BYTE*)Entry->FileDescription, &cb) != ERROR_SUCCESS ||
311 !*Entry->FileDescription;
313 }
314 if (Fallback)
315 {
316 StringCchCopyW(Entry->FileDescription, _countof(Entry->FileDescription), Entry->FileExtension);
317 }
318 }
319 }
320 return Entry->FileDescription;
321}
xD9 x84 xD8 xAD xD9 x80 xF0 x90 xAC x9A xE0 xA7 xA6 xE0 xA7 xAA xF0 x91 x84 xA4 xF0 x91 x84 x89 xF0 x91 x84 x9B xF0 x90 x8A xAB xF0 x90 x8B x89 xE2 xB2 x9E xE2 xB2 x9F xD0 xBE xD0 x9E xF0 x90 x90 x84 xF0 x90 x90 xAC xE1 x83 x98 xE1 x83 x94 xE1 x83 x90 xE2 xB0 x95 xE2 xB1 x85 xCE xBF xCE x9F xE0 xA8 xA0 xE0 xA8 xB0 xE0 xA9 xA6 Kayah xEA xA4 x8D xEA xA4 x80 Khmer xE1 xA7 xA1 xE1 xA7 xAA xE0 xBB x90 Latin Subscript Fallback
Definition: afscript.h:223
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:430
#define SHGFI_TYPENAME
Definition: shellapi.h:168
#define SHGFI_USEFILEATTRIBUTES
Definition: shellapi.h:182
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
WCHAR szTypeName[80]
Definition: shellapi.h:377

Referenced by DECLARE_INTERFACE_(), EditActionDlgProc(), FileTypesDlg_CompareItems(), FileTypesDlg_OnItemChanging(), and FolderOptionsFileTypesDlg().

◆ InitializeDefaultIcons()

static void InitializeDefaultIcons ( PFILE_TYPE_GLOBALS  pG)
static

Definition at line 324 of file filetypes.cpp.

325{
326 const INT ResId = NOASSOCRESID;
327 if (!pG->hDefExtIconSmall)
328 {
330 IMAGE_ICON, pG->IconSize, pG->IconSize, 0));
331 }
332
334 {
336 ASSERT(idx == 0);
337 }
338}
unsigned int idx
Definition: utils.c:41
INT WINAPI ImageList_GetImageCount(HIMAGELIST himl)
Definition: imagelist.c:2063
#define NOASSOCRESID
Definition: filetypes.cpp:34

Referenced by EditTypeDlg_UpdateEntryIcon(), and FileTypesDlg_Refresh().

◆ NewActionDlg_OnOK()

static void NewActionDlg_OnOK ( HWND  hwndDlg,
PACTION_DIALOG  pNewAct 
)
static

Definition at line 940 of file filetypes.cpp.

941{
942 // check action
943 GetDlgItemTextW(hwndDlg, IDC_ACTION_ACTION, pNewAct->szAction, _countof(pNewAct->szAction));
944 StrTrimW(pNewAct->szAction, g_pszSpace);
945 if (pNewAct->szAction[0] == 0)
946 {
947 // action was empty, error
948 HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_ACTION);
949 SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
950 SetFocus(hwndCtrl);
953 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
954 return;
955 }
956
957 // check app
958 GetDlgItemTextW(hwndDlg, IDC_ACTION_APP, pNewAct->szApp, _countof(pNewAct->szApp));
959 StrTrimW(pNewAct->szApp, g_pszSpace);
960 if (pNewAct->szApp[0] == 0 ||
962 {
963 // app was empty or invalid
964 HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_APP);
965 SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
966 SetFocus(hwndCtrl);
969 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
970 return;
971 }
972
973 EndDialog(hwndDlg, IDOK);
974}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by NewActionDlgProc().

◆ NewActionDlgProc()

static INT_PTR CALLBACK NewActionDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 978 of file filetypes.cpp.

979{
980 static PACTION_DIALOG s_pNewAct = NULL;
981
982 switch (uMsg)
983 {
984 case WM_INITDIALOG:
985 s_pNewAct = (PACTION_DIALOG)lParam;
986 s_pNewAct->bUseDDE = FALSE;
988 return TRUE;
989
990 case WM_COMMAND:
991 switch (LOWORD(wParam))
992 {
993 case IDOK:
994 NewActionDlg_OnOK(hwndDlg, s_pNewAct);
995 break;
996
997 case IDCANCEL:
998 EndDialog(hwndDlg, IDCANCEL);
999 break;
1000
1001 case IDC_ACTION_BROWSE:
1002 ActionDlg_OnBrowse(hwndDlg, s_pNewAct, FALSE);
1003 break;
1004 }
1005 break;
1006 }
1007 return 0;
1008}
static void NewActionDlg_OnOK(HWND hwndDlg, PACTION_DIALOG pNewAct)
Definition: filetypes.cpp:940

Referenced by EditTypeDlg_OnCommand().

◆ NewExtDlg_OnAdvanced()

static VOID NewExtDlg_OnAdvanced ( HWND  hwndDlg,
PNEWEXT_DIALOG  pNewExt 
)
static

Definition at line 503 of file filetypes.cpp.

504{
505 // If "Advanced" button was clicked, then we shrink or expand the dialog.
506 RECT rc, rc1, rc2;
507
508 GetWindowRect(hwndDlg, &rc);
509 rc.bottom = rc.top + (pNewExt->rcDlg.bottom - pNewExt->rcDlg.top);
510
511 GetWindowRect(GetDlgItem(hwndDlg, IDOK), &rc1);
512 MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc1, 2);
513
515 MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc2, 2);
516
517 HWND hClassCombo = GetDlgItem(hwndDlg, IDC_NEWEXT_COMBOBOX);
518 if (pNewExt->bAdvanced)
519 {
520 rc1.top += pNewExt->dy;
521 rc1.bottom += pNewExt->dy;
522
523 rc2.top += pNewExt->dy;
524 rc2.bottom += pNewExt->dy;
525
527 ShowWindow(hClassCombo, SW_SHOWNOACTIVATE);
528
530 SetDlgItemTextW(hwndDlg, IDC_NEWEXT_ADVANCED, strLeft);
531
532 SetFocus(hClassCombo);
533 }
534 else
535 {
536 rc1.top -= pNewExt->dy;
537 rc1.bottom -= pNewExt->dy;
538
539 rc2.top -= pNewExt->dy;
540 rc2.bottom -= pNewExt->dy;
541
543 ShowWindow(hClassCombo, SW_HIDE);
544
546 SetDlgItemTextW(hwndDlg, IDC_NEWEXT_ADVANCED, strRight);
547
548 rc.bottom -= pNewExt->dy;
549
550 SendMessageW(hClassCombo, CB_SETCURSEL, 0, 0); // Reset the combo to the "new class" mode
551 }
552
553 HDWP hDWP = BeginDeferWindowPos(3);
554
555 if (hDWP)
556 hDWP = DeferWindowPos(hDWP, GetDlgItem(hwndDlg, IDOK), NULL,
557 rc1.left, rc1.top, rc1.right - rc1.left, rc1.bottom - rc1.top,
559 if (hDWP)
560 hDWP = DeferWindowPos(hDWP, GetDlgItem(hwndDlg, IDCANCEL), NULL,
561 rc2.left, rc2.top, rc2.right - rc2.left, rc2.bottom - rc2.top,
563 if (hDWP)
564 hDWP = DeferWindowPos(hDWP, hwndDlg, NULL,
565 rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
567
568 if (hDWP)
569 EndDeferWindowPos(hDWP);
570}
static const WCHAR rc2[]
Definition: oid.c:1216
#define IDC_NEWEXT_ADVANCED
Definition: shresdef.h:455
#define IDC_NEWEXT_COMBOBOX
Definition: shresdef.h:456
#define IDS_NEWEXT_ADVANCED_RIGHT
Definition: shresdef.h:325
#define IDS_NEWEXT_ADVANCED_LEFT
Definition: shresdef.h:324
#define IDC_NEWEXT_ASSOC
Definition: shresdef.h:457
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
#define SW_HIDE
Definition: winuser.h:771
#define SWP_NOACTIVATE
Definition: winuser.h:1245
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define CB_SETCURSEL
Definition: winuser.h:1964
#define SW_SHOWNOACTIVATE
Definition: winuser.h:777
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOZORDER
Definition: winuser.h:1250
HDWP WINAPI BeginDeferWindowPos(_In_ int)

Referenced by NewExtDlg_OnInitDialog(), and NewExtDlgProc().

◆ NewExtDlg_OnInitDialog()

static BOOL NewExtDlg_OnInitDialog ( HWND  hwndDlg,
PNEWEXT_DIALOG  pNewExt 
)
static

Definition at line 573 of file filetypes.cpp.

574{
575 pNewExt->bAdvanced = FALSE;
576
577 // get window rectangle
578 GetWindowRect(hwndDlg, &pNewExt->rcDlg);
579
580 // get delta Y
581 RECT rc1, rc2;
584 pNewExt->dy = rc2.top - rc1.top;
585
586 // initialize
591
592 // shrink it first time
593 NewExtDlg_OnAdvanced(hwndDlg, pNewExt);
594
595 return TRUE;
596}
static VOID NewExtDlg_OnAdvanced(HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
Definition: filetypes.cpp:503
#define IDS_NEWEXT_NEW
Definition: shresdef.h:326
#define IDC_NEWEXT_EDIT
Definition: shresdef.h:454
WCHAR szExt[16]
Definition: filetypes.cpp:498
#define EM_SETLIMITTEXT
Definition: winuser.h:2014
#define CB_ADDSTRING
Definition: winuser.h:1939

Referenced by NewExtDlgProc().

◆ NewExtDlg_OnOK()

static BOOL NewExtDlg_OnOK ( HWND  hwndDlg,
PNEWEXT_DIALOG  pNewExt 
)
static

Definition at line 599 of file filetypes.cpp.

600{
602 INT iItem;
603
604 GetDlgItemTextW(hwndDlg, IDC_NEWEXT_EDIT, pNewExt->szExt, _countof(pNewExt->szExt));
605 StrTrimW(pNewExt->szExt, g_pszSpace);
606 _wcsupr(pNewExt->szExt);
607
608#if 0
609 // FIXME: Implement the "choose existing class" mode
611 StrTrimW(pNewExt->szFileType, g_pszSpace);
612#endif
613 pNewExt->szFileType[0] = UNICODE_NULL; // "new class" mode
614
615 if (pNewExt->szExt[0] == 0)
616 {
619 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
620 return FALSE;
621 }
622
623 ZeroMemory(&find, sizeof(find));
624 find.flags = LVFI_STRING;
625 if (pNewExt->szExt[0] == L'.')
626 {
627 find.psz = &pNewExt->szExt[1];
628 }
629 else
630 {
631 find.psz = pNewExt->szExt;
632 }
633
634 iItem = ListView_FindItem(pNewExt->hwndLV, -1, &find);
635 if (iItem >= 0)
636 {
637 // already exists
638
639 // get file type
640 WCHAR szFileType[TYPENAME_CCHMAX];
642 ZeroMemory(&item, sizeof(item));
643 item.mask = LVIF_TEXT;
644 item.pszText = szFileType;
645 item.cchTextMax = _countof(szFileType);
646 item.iItem = iItem;
647 item.iSubItem = 1;
648 ListView_GetItem(pNewExt->hwndLV, &item);
649
650 // get text
651 CStringW strText;
652 strText.Format(IDS_NEWEXT_ALREADY_ASSOC, find.psz, szFileType, find.psz, szFileType);
653
654 // get title
655 CStringW strTitle;
657
658 if (MessageBoxW(hwndDlg, strText, strTitle, MB_ICONWARNING | MB_YESNO) == IDNO)
659 {
660 return FALSE;
661 }
662
663 // Delete the extension
664 CStringW strExt(L".");
665 strExt += find.psz;
666 strExt.MakeLower();
667 if (DeleteExt(hwndDlg, strExt))
668 ListView_DeleteItem(pNewExt->hwndLV, iItem);
669 }
670
671 EndDialog(hwndDlg, IDOK);
672 return TRUE;
673}
BOOL LoadString(_In_ UINT nID)
Definition: cstringt.h:639
static TAGID TAGID find
Definition: db.cpp:155
static ATOM item
Definition: dde.c:856
#define LVFI_STRING
Definition: commctrl.h:2442
#define LV_FINDINFO
Definition: commctrl.h:2450
#define LV_ITEM
Definition: commctrl.h:2342
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2475
#define IDS_NEWEXT_SPECIFY_EXT
Definition: shresdef.h:327
#define IDS_NEWEXT_EXT_IN_USE
Definition: shresdef.h:329
#define IDS_NEWEXT_ALREADY_ASSOC
Definition: shresdef.h:328
WCHAR szFileType[64]
Definition: filetypes.cpp:499
#define MB_ICONWARNING
Definition: winuser.h:789

Referenced by NewExtDlgProc().

◆ NewExtDlgProc()

static INT_PTR CALLBACK NewExtDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 677 of file filetypes.cpp.

682{
683 static PNEWEXT_DIALOG s_pNewExt = NULL;
684
685 switch (uMsg)
686 {
687 case WM_INITDIALOG:
688 s_pNewExt = (PNEWEXT_DIALOG)lParam;
689 NewExtDlg_OnInitDialog(hwndDlg, s_pNewExt);
690 return TRUE;
691
692 case WM_COMMAND:
693 switch (LOWORD(wParam))
694 {
695 case IDOK:
696 NewExtDlg_OnOK(hwndDlg, s_pNewExt);
697 break;
698
699 case IDCANCEL:
700 EndDialog(hwndDlg, IDCANCEL);
701 break;
702
704 s_pNewExt->bAdvanced = !s_pNewExt->bAdvanced;
705 NewExtDlg_OnAdvanced(hwndDlg, s_pNewExt);
706 break;
707 }
708 break;
709 }
710 return 0;
711}
static BOOL NewExtDlg_OnInitDialog(HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
Definition: filetypes.cpp:573
static BOOL NewExtDlg_OnOK(HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
Definition: filetypes.cpp:599
struct NEWEXT_DIALOG * PNEWEXT_DIALOG

Referenced by FolderOptionsFileTypesDlg().

◆ Normalize()

static BOOL Normalize ( PFILE_TYPE_ENTRY  Entry)
static

Definition at line 341 of file filetypes.cpp.

342{
343 // We don't need this information until somebody tries to edit the entry
344 if (!Entry->IconPath[0])
345 {
346 StringCbCopyW(Entry->IconPath, sizeof(Entry->IconPath), g_pszShell32);
347 Entry->nIconIndex = NOASSOCRESID > 1 ? -NOASSOCRESID : 0;
348 }
349 return TRUE;
350}
LPCWSTR g_pszShell32

Referenced by __gl_projectPolygon(), EditTypeDlg_UpdateEntryIcon(), and FolderOptionsFileTypesDlg().

◆ PathIsExeW()

EXTERN_C BOOL PathIsExeW ( LPCWSTR  lpszPath)

Definition at line 539 of file shellpath.c.

540{
541 LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
542 int i;
543 static const WCHAR lpszExtensions[][4] =
544 {L"exe", L"com", L"pif", L"cmd", L"bat", L"scf", L"scr", L"" };
545
546 TRACE("path=%s\n",debugstr_w(lpszPath));
547
548 for(i=0; lpszExtensions[i][0]; i++)
549 if (!wcsicmp(lpszExtension,lpszExtensions[i])) return TRUE;
550
551 return FALSE;
552}
static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
Definition: shellpath.c:434
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by FileTypesDlg_InsertToLV().

◆ QueryFileDescription()

static BOOL QueryFileDescription ( LPCWSTR  ProgramPath,
LPWSTR  pszName,
INT  cchName 
)
static

Definition at line 259 of file filetypes.cpp.

260{
261 SHFILEINFOW fi;
263 if (SHGetFileInfoW(ProgramPath, 0, &fi, sizeof(fi), SHGFI_DISPLAYNAME))
264 {
266 return TRUE;
267 }
268 return !!GetFileTitleW(ProgramPath, pszName, cchName);
269}
short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, WORD cbBuf)
Definition: filedlg.c:4856
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:167
WCHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:376
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2792

Referenced by GetAppName().

◆ QuoteAppPathForCommand()

static void QuoteAppPathForCommand ( CStringW path)
static

Definition at line 140 of file filetypes.cpp.

141{
142 if (path.Find(' ') >= 0 && path.Find('\"') < 0)
143 path = CStringW(L"\"") + path + L"\"";
144}
CAtlStringW CStringW
Definition: atlstr.h:130

Referenced by ActionDlg_OnBrowse(), and EditTypeDlg_OnCommand().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( fprop  )