Opc.Ua.Configuration.ConfigUtils.UnregisterComServer C# (CSharp) Method

UnregisterComServer() public static method

Removes the registration for a COM server from the registry.
public static UnregisterComServer ( System.Guid clsid ) : void
clsid System.Guid
return void
        public static void UnregisterComServer(Guid clsid)
        {
			// unregister class in categories.
			string categoriesKey = String.Format(@"CLSID\{{{0}}}\Implemented Categories", clsid);
			
			RegistryKey key = Registry.ClassesRoot.OpenSubKey(categoriesKey);

			if (key != null)
			{
				try	  
				{ 
					foreach (string catid in key.GetSubKeyNames())
					{
						try	  
						{ 
							ConfigUtils.UnregisterClassInCategory(clsid, new Guid(catid.Substring(1, catid.Length-2)));
						}
						catch (Exception)
						{
							// ignore errors.
						}
					}
				}
				finally
				{
					key.Close();
				}
			}

			string progidKey = String.Format(@"CLSID\{{{0}}}\ProgId", clsid);

			// delete prog id.
			key = Registry.ClassesRoot.OpenSubKey(progidKey);
					
			if (key != null)
			{
				string progId = key.GetValue(null) as string;
				key.Close();

				if (!String.IsNullOrEmpty(progId))
				{
					try	  
					{ 
						Registry.ClassesRoot.DeleteSubKeyTree(progId); 
					}
					catch (Exception)
					{
						// ignore errors.
					}
				}
			}

			// delete clsid.
			try	  
			{ 
				Registry.ClassesRoot.DeleteSubKeyTree(String.Format(@"CLSID\{{{0}}}", clsid)); 
			}
			catch (Exception)
			{
				// ignore errors.
			}
        }

Usage Example

コード例 #1
0
ファイル: PseudoComServer.cs プロジェクト: fr830/OPCUA.NET
 /// <summary>
 /// Deletes the pseudoserver from the registry.
 /// </summary>
 public static void Delete(Guid clsid)
 {
     ConfigUtils.UnregisterComServer(clsid);
     DeleteConfiguredEndpointFile(clsid);
 }
All Usage Examples Of Opc.Ua.Configuration.ConfigUtils::UnregisterComServer