// // Remove all traces of this from the registry. // // **TODO** If the above does AppID/DCOM stuff, this would have // to remove that stuff too. // private static void UnregisterObjects() { if (!IsAdministrator) { ElevateSelf("/unregister"); return; } // // Local server's DCOM/AppID information // Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}", s_appId), false); Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}", Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)), false); // // For each of the driver assemblies // foreach (Type type in s_ComObjectTypes) { string clsid = Marshal.GenerateGuidForType(type).ToString("B"); string progid = Marshal.GenerateProgIdForType(type); string deviceType = type.Name; // // Best efforts // // // HKCR\progid // Registry.ClassesRoot.DeleteSubKey(String.Format("{0}\\CLSID", progid), false); Registry.ClassesRoot.DeleteSubKey(progid, false); // // HKCR\CLSID\clsid // Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Implemented Categories\\{{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}}", clsid), false); Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Implemented Categories", clsid), false); Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\ProgId", clsid), false); Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\LocalServer32", clsid), false); Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Programmable", clsid), false); Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}", clsid), false); try { // // ASCOM // using (var P = new ASCOM.Utilities.Profile()) { P.DeviceType = deviceType; P.Unregister(progid); } } catch (Exception) { } } }
// // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // /// <summary> /// Register or unregister the driver with the ASCOM Platform. /// This is harmless if the driver is already registered/unregistered. /// </summary> /// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param> static void RegUnregASCOM(bool bRegister) { using (var P = new ASCOM.Utilities.Profile()) { P.DeviceType = "Camera"; if (bRegister) { P.Register(driverID, driverDescription); } else { P.Unregister(driverID); } } }
// // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // /// <summary> /// Register or unregister the driver with the ASCOM Platform. /// This is harmless if the driver is already registered/unregistered. /// </summary> /// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param> private static void RegUnregASCOM(bool bRegister) { using (var P = new ASCOM.Utilities.Profile()) { P.DeviceType = DRIVER_DEVICE_TYPE; if (bRegister) { P.Register(DRIVER_ID, DRIVER_DESCRIPTION); } else { P.Unregister(DRIVER_ID); } } }
// here are some useful properties and methods that can be used as required // to help with driver development #region ASCOM Registration // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // /// <summary> /// Register or unregister the driver with the ASCOM Platform. /// This is harmless if the driver is already registered/unregistered. /// </summary> /// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param> private static void RegUnregASCOM(bool bRegister) { using (var P = new ASCOM.Utilities.Profile()) { P.DeviceType = "ObservingConditions"; if (bRegister) { P.Register(Const.wiseBoltwoodDriverID, WiseBoltwood.driverDescription); } else { P.Unregister(Const.wiseBoltwoodDriverID); } } }
// here are some useful properties and methods that can be used as required // to help with driver development #region ASCOM Registration // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // /// <summary> /// Register or unregister the driver with the ASCOM Platform. /// This is harmless if the driver is already registered/unregistered. /// </summary> /// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param> private static void RegUnregASCOM(bool bRegister) { using (var P = new ASCOM.Utilities.Profile()) { P.DeviceType = "ObservingConditions"; if (bRegister) { P.Register(OpenWeatherMap.driverID, driverDescription); } else { P.Unregister(OpenWeatherMap.driverID); } } }
// here are some useful properties and methods that can be used as required // to help with driver development #region ASCOM Registration // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // /// <summary> /// Register or unregister the driver with the ASCOM Platform. /// This is harmless if the driver is already registered/unregistered. /// </summary> /// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param> private static void RegUnregASCOM(bool bRegister) { using (var P = new ASCOM.Utilities.Profile()) { P.DeviceType = "FilterWheel"; if (bRegister) { P.Register(WiseFilterWheel.DriverID, WiseFilterWheel.Description); } else { P.Unregister(WiseFilterWheel.DriverID); } } }
// Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // /// <summary> /// Register or unregister the driver with the ASCOM Platform. /// This is harmless if the driver is already registered/unregistered. /// </summary> /// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param> private static void RegUnregASCOM(bool bRegister) { using (var P = new ASCOM.Utilities.Profile()) { P.DeviceType = "Dome"; if (bRegister) { P.Register(driverID, driverDescription); } else { P.Unregister(driverID); } } }
// // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // private static void RegUnregASCOM(bool bRegister) { ASCOM.Utilities.Profile P = new ASCOM.Utilities.Profile(); P.DeviceType = "Focuser"; // Requires Helper 5.0.3 or later if (bRegister) P.Register(s_csDriverID, s_csDriverDescription); else P.Unregister(s_csDriverID); try // In case Helper becomes native .NET { Marshal.ReleaseComObject(P); } catch (Exception) { } P = null; }
// Remove all traces of this from the registry. private static void UnregisterObjects(bool rerunningAsElevated = false) { if (rerunningAsElevated) { if (!IsElevated) { MessageBox.Show("Unable to gain elevated privileges to unregister the Device Hub.\n\n" + "If User Account Control is disabled, please enable it before uninstalling the Device Hub", "DeviceHub", MessageBoxButton.OK, MessageBoxImage.Stop); return; } } else { if (!IsElevated) { // Here we want to elevate a copy of ourselves, unless we are running under the VS Debugger. RerunAsAdministrator("/unregElevated"); return; } } // Local server's DCOM/AppID information Registry.ClassesRoot.DeleteSubKey(String.Format("APPID\\{0}", _appId), false); Registry.ClassesRoot.DeleteSubKey(String.Format("APPID\\{0}", GetExecutableFileName()), false); // For each of the driver assemblies foreach (Type type in _comObjectTypes) { string clsid = Marshal.GenerateGuidForType(type).ToString("B"); string progid = Marshal.GenerateProgIdForType(type); string deviceType = type.Name; // Best efforts // HKCR\progid Registry.ClassesRoot.DeleteSubKey(String.Format("{0}\\CLSID", progid), false); Registry.ClassesRoot.DeleteSubKey(progid, false); // HKCR\CLSID\clsid Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Implemented Categories\\{{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}}", clsid), false); Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Implemented Categories", clsid), false); Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\ProgId", clsid), false); Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\LocalServer32", clsid), false); Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Programmable", clsid), false); Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}", clsid), false); try { // ASCOM using (var P = new ASCOM.Utilities.Profile()) { P.DeviceType = deviceType; P.Unregister(progid); } } catch (Exception) { } } }