public static void Unregister(Guid clsid, string tlbPath) { Trace.WriteLine($"Unregistering server:"); Trace.Indent(); Trace.WriteLine($"CLSID: {clsid:B}"); Trace.Unindent(); // Unregister local server string serverKey = string.Format(KeyFormat.LocalServer32, clsid); Registry.LocalMachine.DeleteSubKey(serverKey, throwOnMissingSubKey: false); // Unregister type library TypeLib.Unregister(tlbPath); }
/// <summary> /// Unregistering server /// </summary> /// <param name="clsid"></param> /// <param name="progId"></param> /// <param name="tlbPath"></param> /// <param name="perUser"></param> static void Unregister(Guid clsid, ProgIdAttribute progId, string tlbPath, bool perUser) { Trace.WriteLine("[Enter]LocalServer.Unregister"); Trace.Indent(); try { Trace.WriteLine($"CLSID: {clsid:B}"); Trace.WriteLine($"progId : {progId?.Value}"); Trace.WriteLine($"tlbPath : {tlbPath}"); Trace.WriteLine($"perUser : {perUser}"); } finally { Trace.Unindent(); } RegistryKey dst; if (perUser) { dst = Registry.CurrentUser; } else { dst = Registry.LocalMachine; } // Unregister local server { string serverKey = string.Format(KeyFormat.formatCLSID, clsid); dst.DeleteSubKeyTree(serverKey, throwOnMissingSubKey: false); } if (progId != null) { //Unregister ProgId var progIdKey = string.Format(KeyFormat.formatProgId, progId.Value); dst.DeleteSubKeyTree(progIdKey, throwOnMissingSubKey: false); } if ((tlbPath != null) && (tlbPath != "")) { TypeLib.Unregister(tlbPath, perUser); } Trace.WriteLine("[Leave]LocalServer.Unregister"); }
public static void Unregister(Guid clsid, string tlbPath) { Trace.WriteLine($"Unregistering server:"); Trace.Indent(); Trace.WriteLine($"CLSID: {clsid:B}"); Trace.Unindent(); // Remove the App ID value string serverKey = string.Format(KeyFormat.CLSID, clsid); using RegistryKey regKey = Registry.LocalMachine.OpenSubKey(serverKey, writable: true); if (regKey != null) { regKey.DeleteValue("AppID"); } // Remove the App ID key string appIdKey = string.Format(KeyFormat.AppID, clsid); Registry.LocalMachine.DeleteSubKey(appIdKey, throwOnMissingSubKey: false); // Unregister type library TypeLib.Unregister(tlbPath); }