public static void Associate(string extension, string description, string icon, string application)
{
var registryKey = Registry.ClassesRoot.CreateSubKey(extension);
if (registryKey != null)
registryKey.SetValue("", PROGRAM_ID);
if (string.IsNullOrEmpty(PROGRAM_ID)) return;
using (var key = Registry.ClassesRoot.CreateSubKey(PROGRAM_ID))
{
if (key == null) return;
if (description != null)
key.SetValue("", description);
if (icon != null)
{
var subKey = key.CreateSubKey("DefaultIcon");
if (subKey != null)
subKey.SetValue("", ToShortPathName(icon));
}
if (application == null) return;
var regKey = key.CreateSubKey(@"Shell\Open\Command");
if (regKey != null)
regKey.SetValue("", ToShortPathName(application) + " \"%1\"");
}
}