Exemplo n.º 1
0
        public static async Task <bool> MainTask(string[] args)
        {
            //var opt = new Windows.System.LauncherOptions()
            //{
            //    TargetApplicationPackageFamilyName = "Microsoft.MicrosoftEdge_8wekyb3d8bbwe"
            //};
            //var items = await Windows.System.Launcher.FindUriSchemeHandlersAsync("microsoft-edge");
            //foreach (var item in items)
            //{
            //    Debug.WriteLine(item.DisplayInfo.DisplayName);
            //}
            //var regApps = Microsoft.Win32.Registry.LocalMachine.
            //    OpenSubKey("SOFTWARE", false).
            //    OpenSubKey("RegisteredApplications", false);
            //foreach (var regApp in regApps.GetValueNames())
            //{
            //    var value = regApps.GetValue(regApp).ToString();
            //    var capabilities = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(value, false) ??
            //        Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64).OpenSubKey(value, false);

            //    var urls = capabilities?.OpenSubKey("URLAssociations", false);
            //    foreach (var url in urls?.GetValueNames() ?? new string[] { })
            //    {
            //        if (url.ToLower() == "microsoft-edge")
            //            Debug.WriteLine(regApp);
            //    }
            //}

            switch (args.Length)
            {
            case 0:
                return(true);

            case 1:
                if (args[0].ToLower() == "microsoft-edge:")
                {
                    return(true);
                }
                else
                {
                    Config.LastUrl = args[0];
                    Config.Save();
                    await Opener.Open(args[0]);

                    return(false);
                }

            default:
                throw new TooManyArgException();
            }
        }