V E L D
V E L D
CC#
Created by V E L D on 6/29/2023 in #help
❔ How to make a method returning type T but only taking subclasses of a certain class ?
I'd like to make a function that takes the type T as an "argument" (T MyMethod<T>()), but the type T must be equal to Type Z or subclass of Type Z, how do I do that ? I'd like it search through defined dictionaries that are all typed as subclasses of Type Z.
64 replies
CC#
Created by V E L D on 6/11/2023 in #help
❔ Associate an application with an extension name (e.g., .asset, .ext, .lol, etc...)
Hello, I would like to know how I can link my app with a custom extension name, in my case it's .rift but it can be any extension name for other apps so I will try to ask as much as possible in a general way. I have read the documentations there: https://learn.microsoft.com/en-us/visualstudio/extensibility/registering-verbs-for-file-name-extensions And here: https://learn.microsoft.com/en-us/windows/win32/shell/how-to-register-a-file-type-for-a-new-application I would like if, first, my code is valid (i'd like to not break my registry before trying) And if not, how can I do that ?
public static void AssociateExtension(string Extension, string Description, string KeyName, string ExecutableName)
{
Registry.SetValue(@"HKEY_CLASSES_ROOT\" + Extension,
"", KeyName);
Registry.SetValue(@"HKEY_CLASSES_ROOT\" + Extension + @"\OpenWithList\" + ExectuableName,
"", "");
Registry.SetValue(@"HKEY_CLASSES_ROOT\" + Extension + @"\OpenWithProgids",
KeyName, "");
Registry.SetValue(@"HKEY_CLASSES_ROOT\Applications\" + ExecutableName + @"\Shell\Open\Command",
"", $"\"{Application.ExecutablePath}\" Project=\"%1\"");
Registry.SetValue(@"HKEY_CLASSES_ROOT\" + KeyName,
"", Description);
//Registry.SetValue(@"HKEY_CLASSES_ROOT\" + KeyName + @"\DefaultIcon", "", "");
Registry.SetValue(@"HKEY_CLASSES_ROOT\" + KeyName + @"\shell\Open\Command",
"", $"\"{Application.ExecutablePath}\" Project=\"%1\"");
}
public static void AssociateExtension(string Extension, string Description, string KeyName, string ExecutableName)
{
Registry.SetValue(@"HKEY_CLASSES_ROOT\" + Extension,
"", KeyName);
Registry.SetValue(@"HKEY_CLASSES_ROOT\" + Extension + @"\OpenWithList\" + ExectuableName,
"", "");
Registry.SetValue(@"HKEY_CLASSES_ROOT\" + Extension + @"\OpenWithProgids",
KeyName, "");
Registry.SetValue(@"HKEY_CLASSES_ROOT\Applications\" + ExecutableName + @"\Shell\Open\Command",
"", $"\"{Application.ExecutablePath}\" Project=\"%1\"");
Registry.SetValue(@"HKEY_CLASSES_ROOT\" + KeyName,
"", Description);
//Registry.SetValue(@"HKEY_CLASSES_ROOT\" + KeyName + @"\DefaultIcon", "", "");
Registry.SetValue(@"HKEY_CLASSES_ROOT\" + KeyName + @"\shell\Open\Command",
"", $"\"{Application.ExecutablePath}\" Project=\"%1\"");
}
Will the output be ?:
3 replies