Exemplo n.º 1
0
        private void AddHandler(DiskCleanupHandler handler)
        {
            var item = new ListViewItem(handler.DisplayName)
            {
                Tag = handler
            };

            var icon = handler.Icon ?? Icons.File;

            imageList.Images.Add(handler.KeyName, icon);
            item.ImageKey = handler.KeyName;

            listView.Items.Add(item);
        }
Exemplo n.º 2
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            var name = Interaction.InputBox("Enter the name of the new item:");

            if (string.IsNullOrWhiteSpace(name))
            {
                return;
            }

            using (var key = RegistryHelper.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\"))
            {
                var subKey = key.CreateSubKey(name);
                subKey.SetValue(null, "{C0E13E61-0CC6-11d1-BBB6-0060978B2AE6}");

                var handler = new DiskCleanupHandler(subKey);
                this.Handlers.Add(handler);
                this.AddHandler(handler);
            }
        }