Remove compatible extensions from registry

This commit is contained in:
Adrien Allard 2021-03-10 09:00:54 +01:00
parent b78a36b022
commit 0088228748
3 changed files with 80 additions and 90 deletions

View File

@ -21,6 +21,84 @@ namespace FileConverter
public static class Helpers
{
public static readonly string[] CompatibleInputExtensions = {
"3gp","aac","aiff","ape","arw","avi","bik","bmp","cda","cr2","dng","doc","docx","exr",
"flac","flv","gif","ico","jpg","jpeg","m4a","m4v","mkv","mov","mp3","mp4","mpeg","nef",
"odp","ods","odt","oga","ogg","ogv","pdf","png","ppt","pptx","psd","raf","svg",
"tga","tif","tiff","vob","wav","webm","webp","wma","wmv","xls","xlsx"
};
public static string GetExtensionCategory(string extension)
{
switch (extension)
{
case "aac":
case "aiff":
case "ape":
case "cda":
case "flac":
case "mp3":
case "m4a":
case "oga":
case "ogg":
case "wav":
case "wma":
return InputCategoryNames.Audio;
case "3gp":
case "avi":
case "bik":
case "flv":
case "m4v":
case "mp4":
case "mpeg":
case "mov":
case "mkv":
case "ogv":
case "vob":
case "webm":
case "wmv":
return InputCategoryNames.Video;
case "arw":
case "bmp":
case "cr2":
case "dng":
case "exr":
case "ico":
case "jpg":
case "jpeg":
case "nef":
case "png":
case "psd":
case "raf":
case "tga":
case "tif":
case "tiff":
case "svg":
case "xcf":
case "webp":
return InputCategoryNames.Image;
case "gif":
return InputCategoryNames.AnimatedImage;
case "pdf":
case "doc":
case "docx":
case "ppt":
case "pptx":
case "odp":
case "ods":
case "odt":
case "xls":
case "xlsx":
return InputCategoryNames.Document;
}
return InputCategoryNames.Misc;
}
public static bool RegisterShellExtension(string shellExtensionPath)
{
if (!Application.IsInAdmininstratorPrivileges)
@ -122,77 +200,6 @@ namespace FileConverter
}
}
public static string GetExtensionCategory(string extension)
{
switch (extension)
{
case "aac":
case "aiff":
case "ape":
case "cda":
case "flac":
case "mp3":
case "m4a":
case "oga":
case "ogg":
case "wav":
case "wma":
return InputCategoryNames.Audio;
case "3gp":
case "avi":
case "bik":
case "flv":
case "m4v":
case "mp4":
case "mpeg":
case "mov":
case "mkv":
case "ogv":
case "vob":
case "webm":
case "wmv":
return InputCategoryNames.Video;
case "arw":
case "bmp":
case "cr2":
case "dng":
case "exr":
case "ico":
case "jpg":
case "jpeg":
case "nef":
case "png":
case "psd":
case "raf":
case "tga":
case "tif":
case "tiff":
case "svg":
case "xcf":
case "webp":
return InputCategoryNames.Image;
case "gif":
return InputCategoryNames.AnimatedImage;
case "pdf":
case "doc":
case "docx":
case "ppt":
case "pptx":
case "odp":
case "ods":
case "odt":
case "xls":
case "xlsx":
return InputCategoryNames.Document;
}
return InputCategoryNames.Misc;
}
public static bool IsOutputTypeCompatibleWithCategory(OutputType outputType, string category)
{
if (category == InputCategoryNames.Misc)

View File

@ -395,26 +395,10 @@ namespace FileConverter.ViewModels
private void InitializeCompatibleInputExtensions()
{
RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\FileConverter");
if (registryKey == null)
{
MessageBox.Show("Can't retrieve the list of compatible input extensions. (code 0x09)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
string registryValue = registryKey.GetValue("CompatibleInputExtensions") as string;
if (registryValue == null)
{
MessageBox.Show("Can't retrieve the list of compatible input extensions. (code 0x0A)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
string[] compatibleInputExtensions = registryValue.Split(';');
List<InputExtensionCategory> categories = new List<InputExtensionCategory>();
for (int index = 0; index < compatibleInputExtensions.Length; index++)
for (int index = 0; index < Helpers.CompatibleInputExtensions.Length; index++)
{
string compatibleInputExtension = compatibleInputExtensions[index];
string compatibleInputExtension = Helpers.CompatibleInputExtensions[index];
string extensionCategory = Helpers.GetExtensionCategory(compatibleInputExtension);
InputExtensionCategory category = categories.Find(match => match.Name == extensionCategory);
if (category == null)

View File

@ -168,7 +168,6 @@
<Component Id="RegistryEntries" Guid="{1862E9DC-1B37-4AFD-85BF-2E9CFFAFA9F8}">
<RegistryKey Root="HKCU" Key="Software\FileConverter" ForceDeleteOnUninstall="yes">
<RegistryValue Name="Path" Type="string" Value="[INSTALLFOLDER]FileConverter.exe"/>
<RegistryValue Name="CompatibleInputExtensions" Type="string" Value="3gp;aac;aiff;ape;arw;avi;bik;bmp;cda;cr2;dng;doc;docx;exr;flac;flv;gif;ico;jpg;jpeg;m4a;m4v;mkv;mov;mp3;mp4;mpeg;nef;odp;ods;odt;oga;ogg;ogv;pdf;png;ppt;pptx;psd;raf;svg;tga;tif;tiff;vob;wav;webm;webp;wma;wmv;xls;xlsx"/>
</RegistryKey>
</Component>
</ComponentGroup>