[SHELL32] Allow deleting a file type/extension (#553)

CORE-12906
This commit is contained in:
Katayama Hirofumi MZ 2018-05-19 23:12:11 +09:00 committed by Hermès BÉLUSCA - MAÏTO
parent d7e40954d5
commit 82a5983504
34 changed files with 128 additions and 0 deletions

View File

@ -1349,6 +1349,30 @@ FindItem(HWND hDlgCtrl, WCHAR * ItemName)
return ListView_FindItem(hDlgCtrl, 0, &findInfo);
}
static BOOL
DeleteExt(HWND hwndDlg, LPCWSTR pszExt)
{
if (*pszExt != L'.')
return FALSE;
HKEY hKey;
LONG nResult = RegOpenKeyExW(HKEY_CLASSES_ROOT, pszExt, 0, KEY_READ, &hKey);
if (nResult != ERROR_SUCCESS)
return FALSE;
WCHAR szValue[64];
DWORD cbValue = sizeof(szValue);
nResult = RegQueryValueExW(hKey, NULL, NULL, NULL, LPBYTE(szValue), &cbValue);
RegCloseKey(hKey);
if (nResult != ERROR_SUCCESS)
return FALSE;
if (szValue[0])
SHDeleteKeyW(HKEY_CLASSES_ROOT, szValue);
return SHDeleteKeyW(HKEY_CLASSES_ROOT, pszExt) == ERROR_SUCCESS;
}
static
VOID
InsertFileType(HWND hDlgCtrl, WCHAR * szName, PINT iItem, WCHAR * szFile)
@ -1749,6 +1773,12 @@ NewExtDlg_OnOK(HWND hwndDlg, NEWEXT_DIALOG *pNewExt)
return FALSE;
}
// Delete the extension
CStringW strExt(L".");
strExt += find.psz;
strExt.MakeLower();
DeleteExt(hwndDlg, strExt);
// Delete the item
ListView_DeleteItem(pNewExt->hwndLV, iItem);
}
@ -1873,6 +1903,28 @@ FileTypesDlg_AddExt(HWND hwndDlg, LPCWSTR pszExt, LPCWSTR pszFileType)
return TRUE;
}
static BOOL
FileTypesDlg_RemoveExt(HWND hwndDlg)
{
HWND hListView = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
INT iItem = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
if (iItem == -1)
return FALSE;
WCHAR szExt[20];
szExt[0] = L'.';
ListView_GetItemText(hListView, iItem, 0, &szExt[1], _countof(szExt) - 1);
CharLowerW(szExt);
if (DeleteExt(hwndDlg, szExt))
{
ListView_DeleteItem(hListView, iItem);
return TRUE;
}
return FALSE;
}
// IDD_FOLDER_OPTIONS_FILETYPES dialog
INT_PTR
CALLBACK
@ -1911,6 +1963,16 @@ FolderOptionsFileTypesDlg(
FileTypesDlg_AddExt(hwndDlg, newext.szExt, newext.szFileType);
}
break;
case IDC_FILETYPES_DELETE:
{
CStringW strRemoveExt(MAKEINTRESOURCEW(IDS_REMOVE_EXT));
CStringW strTitle(MAKEINTRESOURCEW(IDS_FILE_TYPES));
if (MessageBoxW(hwndDlg, strRemoveExt, strTitle, MB_ICONQUESTION | MB_YESNO) == IDYES)
{
FileTypesDlg_RemoveExt(hwndDlg);
}
}
break;
case IDC_FILETYPES_CHANGE:
pItem = FindSelectedItem(GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW));
if (pItem)

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -885,4 +885,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -905,4 +905,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -900,4 +900,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -900,4 +900,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -901,4 +901,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -907,4 +907,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -896,4 +896,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -904,4 +904,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "Musisz podać rozszerzenie."
IDS_NEWEXT_ALREADY_ASSOC "Rozszerzenie %s jest już związane z typem plików %s. Czy chcesz usunąć powiązanie %s z %s i utworzyć dla niego nowy typ plików?"
IDS_NEWEXT_EXT_IN_USE "Rozszerzenie jest w użyciu"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -901,4 +901,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -901,4 +901,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -903,4 +903,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -901,4 +901,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -899,4 +899,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -909,4 +909,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -907,4 +907,6 @@ BEGIN
IDS_NEWEXT_SPECIFY_EXT "You must specify an extension."
IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?"
IDS_NEWEXT_EXT_IN_USE "Extension is in use"
IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?"
END

View File

@ -266,6 +266,8 @@
#define IDS_NEWEXT_ALREADY_ASSOC 30520
#define IDS_NEWEXT_EXT_IN_USE 30521
#define IDS_REMOVE_EXT 30522
/* Dialogs */
/* Run dialog */