private static string RemoveFileAssociationProgIDInfo(FileAssociation fileAssociation, DefinitionIdentity subId, RegistryKey classesKey, string productName) { string str = null; using (RegistryKey key = classesKey.OpenSubKey(fileAssociation.ProgID, true)) { if (key == null) { return(null); } object obj2 = key.GetValue("AppId"); if (!(obj2 is string)) { return(null); } string a = (string)obj2; if (!string.Equals(a, subId.ToString(), StringComparison.Ordinal)) { return(null); } str = (string)key.GetValue("Guid"); try { classesKey.DeleteSubKeyTree(fileAssociation.ProgID); } catch (ArgumentException exception) { throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssocProgIdDeleteFailed"), new object[] { fileAssociation.ProgID, productName }), exception); } } return(str); }
private static void RemoveFileAssociationExtentionInfo(FileAssociation fileAssociation, DefinitionIdentity subId, RegistryKey classesKey, string productName) { using (RegistryKey key = classesKey.OpenSubKey(fileAssociation.Extension, true)) { if (key != null) { object obj2 = key.GetValue("AppId"); if (obj2 is string) { string a = (string)obj2; if (string.Equals(a, subId.ToString(), StringComparison.Ordinal)) { try { classesKey.DeleteSubKeyTree(fileAssociation.Extension); } catch (ArgumentException exception) { throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssocExtDeleteFailed"), new object[] { fileAssociation.Extension, productName }), exception); } } } } } }
private static void RemoveFileAssociationExtentionInfo(FileAssociation fileAssociation, DefinitionIdentity subId, RegistryKey classesKey, string productName) { using (RegistryKey registryKey = classesKey.OpenSubKey(fileAssociation.Extension, true)) { if (registryKey == null) { return; } object obj = registryKey.GetValue("AppId"); if (!(obj is string)) { return; } if (!string.Equals((string)obj, subId.ToString(), StringComparison.Ordinal)) { return; } try { classesKey.DeleteSubKeyTree(fileAssociation.Extension); } catch (ArgumentException ex) { throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssocExtDeleteFailed"), new object[2] { (object)fileAssociation.Extension, (object)productName }), (Exception)ex); } } }
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"); } } } } }
private static void AddFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, Uri deploymentProviderUri) { if (CanAddFileAssociation(fileAssociation)) { string str = Guid.NewGuid().ToString("B"); string str2 = subId.ToString(); using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Classes")) { using (RegistryKey key2 = key.CreateSubKey(fileAssociation.Extension)) { key2.SetValue(null, fileAssociation.ProgID); key2.SetValue("AppId", str2); key2.SetValue("Guid", str); key2.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri); } using (RegistryKey key3 = key.CreateSubKey(fileAssociation.ProgID)) { key3.SetValue(null, fileAssociation.Description); key3.SetValue("AppId", str2); key3.SetValue("Guid", str); key3.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri); using (RegistryKey key4 = key3.CreateSubKey("shell")) { key4.SetValue(null, "open"); using (RegistryKey key5 = key4.CreateSubKey(@"open\command")) { key5.SetValue(null, "rundll32.exe dfshim.dll, ShOpenVerbExtension " + str + " %1"); Logger.AddInternalState("File association created. Extension=" + fileAssociation.Extension + " value=rundll32.exe dfshim.dll, ShOpenVerbExtension " + str + " %1"); } using (RegistryKey key6 = key3.CreateSubKey(@"shellex\IconHandler")) { key6.SetValue(null, str); Logger.AddInternalState("File association icon handler created. Extension=" + fileAssociation.Extension + " value=" + str); } } } using (RegistryKey key7 = key.CreateSubKey("CLSID")) { using (RegistryKey key8 = key7.CreateSubKey(str)) { key8.SetValue(null, "Shell Icon Handler For " + fileAssociation.Description); key8.SetValue("AppId", str2); key8.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri); key8.SetValue("IconFile", fileAssociation.DefaultIcon); using (RegistryKey key9 = key8.CreateSubKey("InProcServer32")) { key9.SetValue(null, "dfshim.dll"); key9.SetValue("ThreadingModel", "Apartment"); } } } } } }
internal static System.Deployment.Application.DefinitionIdentity GetDefinitionIdentityFromManagedAssembly(string filePath) { Guid guidOfType = System.Deployment.Internal.Isolation.IsolationInterop.GetGuidOfType(typeof(System.Deployment.Internal.Isolation.IReferenceIdentity)); System.Deployment.Internal.Isolation.IReferenceIdentity assemblyIdentityFromFile = (System.Deployment.Internal.Isolation.IReferenceIdentity) System.Deployment.Application.NativeMethods.GetAssemblyIdentityFromFile(filePath, ref guidOfType); System.Deployment.Application.ReferenceIdentity refId = new System.Deployment.Application.ReferenceIdentity(assemblyIdentityFromFile); string processorArchitecture = refId.ProcessorArchitecture; if (processorArchitecture != null) { refId.ProcessorArchitecture = processorArchitecture.ToLower(CultureInfo.InvariantCulture); } System.Deployment.Application.DefinitionIdentity identity3 = new System.Deployment.Application.DefinitionIdentity(refId); Logger.AddInternalState("Managed Assembly Identity = " + identity3.ToString()); return identity3; }
internal static System.Deployment.Application.DefinitionIdentity GetDefinitionIdentityFromManagedAssembly(string filePath) { Guid guidOfType = System.Deployment.Internal.Isolation.IsolationInterop.GetGuidOfType(typeof(System.Deployment.Internal.Isolation.IReferenceIdentity)); System.Deployment.Internal.Isolation.IReferenceIdentity assemblyIdentityFromFile = (System.Deployment.Internal.Isolation.IReferenceIdentity)System.Deployment.Application.NativeMethods.GetAssemblyIdentityFromFile(filePath, ref guidOfType); System.Deployment.Application.ReferenceIdentity refId = new System.Deployment.Application.ReferenceIdentity(assemblyIdentityFromFile); string processorArchitecture = refId.ProcessorArchitecture; if (processorArchitecture != null) { refId.ProcessorArchitecture = processorArchitecture.ToLower(CultureInfo.InvariantCulture); } System.Deployment.Application.DefinitionIdentity identity3 = new System.Deployment.Application.DefinitionIdentity(refId); Logger.AddInternalState("Managed Assembly Identity = " + identity3.ToString()); return(identity3); }
private static string RemoveFileAssociationProgIDInfo(FileAssociation fileAssociation, DefinitionIdentity subId, RegistryKey classesKey, string productName) { string str = null; using (RegistryKey key = classesKey.OpenSubKey(fileAssociation.ProgID, true)) { if (key == null) { return null; } object obj2 = key.GetValue("AppId"); if (!(obj2 is string)) { return null; } string a = (string) obj2; if (!string.Equals(a, subId.ToString(), StringComparison.Ordinal)) { return null; } str = (string) key.GetValue("Guid"); try { classesKey.DeleteSubKeyTree(fileAssociation.ProgID); } catch (ArgumentException exception) { throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssocProgIdDeleteFailed"), new object[] { fileAssociation.ProgID, productName }), exception); } } return str; }
private static void RemoveFileAssociationExtentionInfo(FileAssociation fileAssociation, DefinitionIdentity subId, RegistryKey classesKey, string productName) { using (RegistryKey key = classesKey.OpenSubKey(fileAssociation.Extension, true)) { if (key != null) { object obj2 = key.GetValue("AppId"); if (obj2 is string) { string a = (string) obj2; if (string.Equals(a, subId.ToString(), StringComparison.Ordinal)) { try { classesKey.DeleteSubKeyTree(fileAssociation.Extension); } catch (ArgumentException exception) { throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssocExtDeleteFailed"), new object[] { fileAssociation.Extension, productName }), exception); } } } } } }
private static void UpdateArpEntry(SubscriptionState subState, ShellExposureInformation shellExposureInformation) { DefinitionIdentity subscriptionId = subState.SubscriptionId; string str = string.Format(CultureInfo.InvariantCulture, "rundll32.exe dfshim.dll,ShArpMaintain {0}", new object[] { subscriptionId.ToString() }); string str2 = string.Format(CultureInfo.InvariantCulture, "dfshim.dll,2", new object[0]); AssemblyManifest currentDeploymentManifest = subState.CurrentDeploymentManifest; Description effectiveDescription = subState.EffectiveDescription; using (RegistryKey key = UninstallRoot.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")) { using (RegistryKey key2 = key.CreateSubKey(GenerateArpKeyName(subscriptionId))) { string[] strArray = new string[] { "DisplayName", shellExposureInformation.ARPDisplayName, "DisplayIcon", str2, "DisplayVersion", currentDeploymentManifest.Identity.Version.ToString(), "Publisher", effectiveDescription.FilteredPublisher, "UninstallString", str, "HelpLink", effectiveDescription.SupportUrl, "UrlUpdateInfo", subState.DeploymentProviderUri.AbsoluteUri, "ShortcutFolderName", shellExposureInformation.AppVendor, "ShortcutFileName", shellExposureInformation.AppProduct, "ShortcutSuiteName", shellExposureInformation.AppSuiteName, "SupportShortcutFileName", shellExposureInformation.AppSupportShortcut, "ShortcutAppId", shellExposureInformation.ShortcutAppId }; Logger.AddInternalState("Updating ARP entry."); for (int i = strArray.Length - 2; i >= 0; i -= 2) { string name = strArray[i]; string str4 = strArray[i + 1]; if (str4 != null) { key2.SetValue(name, str4); } else { key2.DeleteValue(name, false); } } } } }