public void Registry_Update_Throws()
        {
            try
            {
                var asm       = Assembly.GetExecutingAssembly();
                var settings  = new SettingsFolder(asm, IO);
                var path      = @"C:\Program Files\CubeICE\cubeice.exe";
                var registrar = new AssociateRegistrar(path)
                {
                    Arguments = new List <string> {
                        "/x"
                    },
                    IconLocation = $"{path},{settings.Value.Associate.IconIndex}",
                    ToolTip      = false,
                };

                registrar.Update(settings.Value.Associate.Value);

                foreach (var key in settings.Value.Associate.Value.Keys.ToArray())
                {
                    settings.Value.Associate.Value[key] = false;
                }
                registrar.Update(settings.Value.Associate.Value);

                Assert.Pass("Administrator");
            }
            catch (UnauthorizedAccessException err) { Assert.Pass(err.Message); }
        }
예제 #2
0
        public void Update()
        {
            try
            {
                var settings  = new SettingFolder();
                var path      = @"C:\Program Files\CubeICE\cubeice.exe";
                var registrar = new AssociateRegistrar(path)
                {
                    IconLocation = $"{path},{settings.Value.Associate.IconIndex}",
                    ToolTip      = false,
                };

                registrar.Update(settings.Value.Associate.Value);

                foreach (var key in settings.Value.Associate.Value.Keys.ToArray())
                {
                    settings.Value.Associate.Value[key] = false;
                }
                registrar.Update(settings.Value.Associate.Value);

                Assert.Pass("Administrator");
            }
            catch (UnauthorizedAccessException err) { Assert.Ignore(err.Message); }
        }
예제 #3
0
        static void Main(string[] args)
        {
            var type = typeof(Program);

            try
            {
                Logger.Configure();
                Logger.Info(type, Assembly.GetExecutingAssembly());
                Logger.Info(type, string.Join(" ", args));

                var asm      = Assembly.GetExecutingAssembly();
                var settings = new SettingsFolder(asm, new AfsIO());
                if (args.Length > 0 && args[0].ToLowerInvariant() == "/uninstall")
                {
                    Clear(settings);
                }
                else
                {
                    settings.Load();
                }

                var dir  = System.IO.Path.GetDirectoryName(asm.Location);
                var exe  = System.IO.Path.Combine(dir, "cubeice.exe");
                var icon = $"{exe},{settings.Value.Associate.IconIndex}";

                Logger.Info(type, $"FileName:{exe}");
                Logger.Info(type, $"IconLocation:{icon}");

                var registrar = new AssociateRegistrar(exe)
                {
                    IconLocation = icon,
                    ToolTip      = settings.Value.ToolTip,
                };

                registrar.Arguments = PresetMenu.Extract.ToArguments();
                registrar.Update(settings.Value.Associate.Value);

                Shell32.NativeMethods.SHChangeNotify(
                    0x08000000, // SHCNE_ASSOCCHANGED
                    0x00001000, // SHCNF_FLUSH
                    IntPtr.Zero,
                    IntPtr.Zero
                    );
            }
            catch (Exception err) { Logger.Error(type, err); }
        }
예제 #4
0
        static void Main(string[] args) => Source.LogError(() =>
        {
            Source.LogInfo(Source.Assembly);
            Source.LogInfo($"[ {args.Join(" ")} ]");

            var src = new SettingFolder();
            if (args.Length > 0 && args[0].ToLowerInvariant() == "/uninstall")
            {
                Clear(src);
            }
            else
            {
                src.Load();
            }

            var dir  = Source.Assembly.GetDirectoryName();
            var exe  = System.IO.Path.Combine(dir, "cubeice.exe");
            var icon = $"{exe},{src.Value.Associate.IconIndex}";

            Source.LogInfo($"FileName:{exe}");
            Source.LogInfo($"IconLocation:{icon}");

            var registrar = new AssociateRegistrar(exe)
            {
                IconLocation = icon,
                ToolTip      = src.Value.ToolTip,
            };

            registrar.Update(src.Value.Associate.Value);

            Shell32.NativeMethods.SHChangeNotify(
                0x08000000, // SHCNE_ASSOCCHANGED
                0x00001000, // SHCNF_FLUSH
                IntPtr.Zero,
                IntPtr.Zero
                );
        });