コード例 #1
0
        private static CommandItem CreateItem(Process proc)
        {
            CommandItem app = null;

            if (proc.MainWindowTitle.Length > 1)
            {
                app = RunningAppItem.build(proc);
            }

            return(app);
        }
コード例 #2
0
        private static bool IsValid(RunningAppItem command)
        {
            if (command == null)
            {
                return(false);
            }

            using (var appx = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Appx"))
            {
                var packageRoot = appx.GetValue("PackageRoot");
                if (command.Path.IndexOf(packageRoot.ToString()) == 0)
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
        static public RunningAppItem build(Process proc)
        {
            RunningAppItem command = null;

            try
            {
                command = new RunningAppItem(proc);
            }
            catch (NullReferenceException)
            {
                // ignore
            }

            if (!IsValid(command))
            {
                command = null;
            }

            return(command);
        }