private static void AddFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, Uri deploymentProviderUri) { if (!ShellExposure.CanAddFileAssociation(fileAssociation)) { return; } string subkey = Guid.NewGuid().ToString("B"); string str = subId.ToString(); using (RegistryKey subKey1 = Registry.CurrentUser.CreateSubKey("Software\\Classes")) { using (RegistryKey subKey2 = subKey1.CreateSubKey(fileAssociation.Extension)) { subKey2.SetValue((string)null, (object)fileAssociation.ProgID); subKey2.SetValue("AppId", (object)str); subKey2.SetValue("Guid", (object)subkey); subKey2.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri); } using (RegistryKey subKey2 = subKey1.CreateSubKey(fileAssociation.ProgID)) { subKey2.SetValue((string)null, (object)fileAssociation.Description); subKey2.SetValue("AppId", (object)str); subKey2.SetValue("Guid", (object)subkey); subKey2.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri); using (RegistryKey subKey3 = subKey2.CreateSubKey("shell")) { subKey3.SetValue((string)null, (object)"open"); using (RegistryKey subKey4 = subKey3.CreateSubKey("open\\command")) { subKey4.SetValue((string)null, (object)("rundll32.exe dfshim.dll, ShOpenVerbExtension " + subkey + " %1")); Logger.AddInternalState("File association created. Extension=" + fileAssociation.Extension + " value=rundll32.exe dfshim.dll, ShOpenVerbExtension " + subkey + " %1"); } using (RegistryKey subKey4 = subKey2.CreateSubKey("shellex\\IconHandler")) { subKey4.SetValue((string)null, (object)subkey); Logger.AddInternalState("File association icon handler created. Extension=" + fileAssociation.Extension + " value=" + subkey); } } } using (RegistryKey subKey2 = subKey1.CreateSubKey("CLSID")) { using (RegistryKey subKey3 = subKey2.CreateSubKey(subkey)) { subKey3.SetValue((string)null, (object)("Shell Icon Handler For " + fileAssociation.Description)); subKey3.SetValue("AppId", (object)str); subKey3.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri); subKey3.SetValue("IconFile", (object)fileAssociation.DefaultIcon); using (RegistryKey subKey4 = subKey3.CreateSubKey("InProcServer32")) { subKey4.SetValue((string)null, (object)"dfshim.dll"); subKey4.SetValue("ThreadingModel", (object)"Apartment"); } } } } }