C
C#2y ago
V E L D

❔ 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 ?:
2 Replies
V E L D
V E L DOP2y ago
(Refer to arguments name in my function higher)
[HKEY_CLASSES_ROOT\Extension]
@="KeyName"

[HKEY_CLASSES_ROOT\Extension\OpenWithList]
[HKEY_CLASSES_ROOT\Extension\OpenWithList\VSLauncher.exe]
@=""

[HKEY_CLASSES_ROOT\Extension\OpenWithProgids]
"KeyName"=""

[HKEY_CLASSES_ROOT\Applications\ExecutableName]
[HKEY_CLASSES_ROOT\Applications\ExecutableName\Shell]
[HKEY_CLASSES_ROOT\Applications\ExecutableName\Shell\Open]
[HKEY_CLASSES_ROOT\Applications\ExecutableName\Shell\Open\Command]
@="\"Application.ExecutablePath\" Project=\"%1\""

[HKEY_CLASSES_ROOT\KeyName]
@="Description"

# Ignore this
#[HKEY_CLASSES_ROOT\VisualStudio.csproj.8.0\DefaultIcon]
#@="C:\\VisualStudioPath\\VC#\\VCSPackages\\csproj.dll,0"

[HKEY_CLASSES_ROOT\KeyName\shell]
[HKEY_CLASSES_ROOT\KeyName\shell\Open]
[HKEY_CLASSES_ROOT\KeyName\shell\Open\Command]
@="\"Application.ExecutablePath\" Project=\"%1\""
[HKEY_CLASSES_ROOT\Extension]
@="KeyName"

[HKEY_CLASSES_ROOT\Extension\OpenWithList]
[HKEY_CLASSES_ROOT\Extension\OpenWithList\VSLauncher.exe]
@=""

[HKEY_CLASSES_ROOT\Extension\OpenWithProgids]
"KeyName"=""

[HKEY_CLASSES_ROOT\Applications\ExecutableName]
[HKEY_CLASSES_ROOT\Applications\ExecutableName\Shell]
[HKEY_CLASSES_ROOT\Applications\ExecutableName\Shell\Open]
[HKEY_CLASSES_ROOT\Applications\ExecutableName\Shell\Open\Command]
@="\"Application.ExecutablePath\" Project=\"%1\""

[HKEY_CLASSES_ROOT\KeyName]
@="Description"

# Ignore this
#[HKEY_CLASSES_ROOT\VisualStudio.csproj.8.0\DefaultIcon]
#@="C:\\VisualStudioPath\\VC#\\VCSPackages\\csproj.dll,0"

[HKEY_CLASSES_ROOT\KeyName\shell]
[HKEY_CLASSES_ROOT\KeyName\shell\Open]
[HKEY_CLASSES_ROOT\KeyName\shell\Open\Command]
@="\"Application.ExecutablePath\" Project=\"%1\""
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server