private ProgramList.ID GetIDforEntry(string path, int processId)
        {
            ProgramList.Types type = ProgramList.Types.Global;
            string            name = null;

            if (path.Equals("System", StringComparison.OrdinalIgnoreCase))
            {
                type = ProgramList.Types.System;
            }
            else
            {
                path = MiscFunc.parsePath(path);
                if (path.Length == 0) // fallback
                {
                    path = ProgramList.GetProcessPathById(processId);
                    if (path == null)
                    {
                        return(null);
                    }
                }

                //if (Path.GetFileName(path).Equals("svchost.exe", StringComparison.OrdinalIgnoreCase))
                List <ServiceHelper.ServiceInfo> Services = ServiceHelper.GetServicesByPID(processId);
                if (Services != null)
                {
                    type = ProgramList.Types.Service;
                    if (Services.Count > 1)
                    {
                        // ToDo: handle teh case Services.length > 1 !!!!
                        Console.WriteLine("Non unique service " + Services.Count);
                    }
                    name = Services[0].ServiceName;
                }
                else
                {
                    name = App.engine.appMgr != null?App.engine.appMgr.GetAppPackage(path) : null;

                    if (name != null)
                    {
                        type = ProgramList.Types.App;
                    }
                    else
                    {
                        type = ProgramList.Types.Program;
                    }
                }
            }
            ProgramList.ID id = new ProgramList.ID(type, path, name);
            id.MakeDisplayName();
            return(id);
        }
Exemplo n.º 2
0
 public bool Load(XmlNode entryNode)
 {
     foreach (XmlNode node in entryNode.ChildNodes)
     {
         if (node.Name == "id")
         {
             ProgramList.ID id = new ProgramList.ID();
             if (id.Load(node))
             {
                 id.MakeDisplayName();
                 IDs.Add(id);
             }
         }
         else if (node.Name == "Name")
         {
             config.Name = node.InnerText;
         }
         else if (node.Name == "Category")
         {
             config.Category = node.InnerText;
         }
         else if (node.Name == "Icon")
         {
             config.Icon = node.InnerText;
         }
         else if (node.Name == "NetAccess")
         {
             Enum.TryParse(node.InnerText, out config.NetAccess);
         }
         else if (node.Name == "Notify")
         {
             config.Notify = MiscFunc.parseBool(node.InnerText, null);
         }
         else
         {
             AppLog.Line("Unknown Program Value, '{0}':{1}", node.Name, node.InnerText);
         }
     }
     return(IDs.Count > 0 && config.Name != null);
 }