VS05,VS08清除最近浏览项目记录软件

以前VS项目记录浏览很多,要清除还得打开注册表进行手动清除,很是麻烦,自己为了方便就做了一个清除软件,方便,快速的解决了这一问题,于是给大家分享一下,不足之处还望留言,我会改善。

1.清除VS项目记录,如图:

2.清除VS项目文件记录,如图:

 

源码实现,参考:

private RegistryKey ProjectKey = null;
        private RegistryKey FileKey = null;
        private void button1_Click(object sender, EventArgs e)
        {
            getPKeyValuArray();
        }

        public void getPKeyValuArray()
        {
            try
            {
                listView1.Items.Clear();
                RegistryKey hklm = Registry.CurrentUser;

                string strVSKey = "";
                switch (cbVsList.SelectedIndex)
                {
                    case 0:
                        strVSKey = "8.0";
                        break;
                    case 1:
                        strVSKey = "9.0";
                        break;
                   default:
                        break;
                }
                RegistryKey software = hklm.OpenSubKey("Software");
                //打开"SOFTWARE/Microsoft/VisualStudio"子键
                ProjectKey = software.OpenSubKey("Microsoft", true).OpenSubKey("VisualStudio", true).OpenSubKey(strVSKey, true).OpenSubKey("ProjectMRUList", true);
                //打开"ProjectMRUList"子键
                string[] arrSubItem = new string[2];
                string[] sitekeyValue = ProjectKey.GetValueNames();
                //开始遍历由键值字符串数组
                int iCount = 0; int iconIndex = 1;
                foreach (string site in sitekeyValue)
                {
                    arrSubItem[0] = site;
                    arrSubItem[1] = ProjectKey.GetValue(site).ToString();
                    ListViewItem LiItem = new ListViewItem(arrSubItem, iconIndex);
                    listView1.Items.Insert(iCount, LiItem);
                    iCount++;
                    iconIndex++;
                }
            }
            catch { }
        }
       
        private void btPDelete_Click(object sender, EventArgs e)
        {
            if(listView1.FocusedItem==null){ return; }
            try
            {
                string deteleKeyValue = listView1.FocusedItem.Text;
                ProjectKey.DeleteValue(deteleKeyValue);
                MessageBox.Show("删除成功!");
                getPKeyValuArray();
            }
            catch { }
           

        }

        private void btFile_Click(object sender, EventArgs e)
        {
            getFKeyValueArray();
        }

        public void getFKeyValueArray()
        {
            try
            {
                listView2.Items.Clear();
                RegistryKey hklm = Registry.CurrentUser;

                string strVSKey = "";
                switch (cbVsList.SelectedIndex)
                {
                    case 0:
                        strVSKey = "8.0";
                        break;
                    case 1:
                        strVSKey = "9.0";
                        break;
                   default:
                        break;
                }
                RegistryKey software = hklm.OpenSubKey("Software");
                //打开"SOFTWARE/Microsoft/VisualStudio"子键
                FileKey = software.OpenSubKey("Microsoft", true).OpenSubKey("VisualStudio", true).OpenSubKey(strVSKey, true).OpenSubKey("FileMRUList", true);
                //打开"ProjectMRUList"子键
                string[] arrSubItem = new string[2];
                string[] sitekeyValue = FileKey.GetValueNames();
                //开始遍历由键值字符串数组
                int iCount = 0; int iconIndex = 1;
                foreach (string site in sitekeyValue)
                {
                    arrSubItem[0] = site;
                    arrSubItem[1] = FileKey.GetValue(site).ToString();
                    ListViewItem LiItem = new ListViewItem(arrSubItem, iconIndex);
                    listView2.Items.Insert(iCount, LiItem);
                    iCount++;
                    iconIndex++;
                }
            }
            catch { }
        }

        private void btFDelete_Click(object sender, EventArgs e)
        {
            if (listView2.FocusedItem == null) { return; }
            try
            {
                string deteleKeyValue = listView2.FocusedItem.Text;
                FileKey.DeleteValue(deteleKeyValue);
                MessageBox.Show("删除成功!");
                getFKeyValueArray();
            }
            catch { }
           
        }

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值