public static EnumClassesInCategory ( System.Guid category ) : List |
||
category | System.Guid | |
return | List |
/// <summary> /// Returns the UA COM Pseudo-servers registered on the local computer. /// </summary> public static List <ConfiguredEndpoint> Enumerate() { // enumerate server clsids. List <Guid> clsids = ConfigUtils.EnumClassesInCategory(ConfigUtils.CATID_PseudoComServers); // initialize server objects. List <ConfiguredEndpoint> servers = new List <ConfiguredEndpoint>(); for (int ii = 0; ii < clsids.Count; ii++) { ConfiguredEndpoint server = null; try { server = Load(clsids[ii]); servers.Add(server); } catch (Exception e) { Utils.Trace(e, "Unexpected error loading psuedo-server: {0}", clsids[ii]); continue; } // ensure the Pseudo-server points to the correct host process. Guid hostClsid = Guid.Empty; if (server.ComIdentity != null) { hostClsid = GetServerHostClsid(server.ComIdentity.Specification); } string hostPath = ConfigUtils.GetExecutablePath(hostClsid); if (String.IsNullOrEmpty(hostPath)) { continue; } RegistryKey key = Registry.ClassesRoot.OpenSubKey(String.Format(@"CLSID\{{{0}}}\LocalServer32", clsids[ii]), false); if (key != null) { if (hostPath != (string)key.GetValue(null, "")) { try { key.Close(); key = Registry.ClassesRoot.OpenSubKey( String.Format(@"CLSID\{{{0}}}\LocalServer32", clsids[ii]), true); key.SetValue(null, hostPath); } catch (Exception) { Utils.Trace("Could not update COM proxy server path for {0}.", server.ComIdentity.ProgId); } } key.Close(); } } return(servers); }