Click here to Skip to main content
12,450,977 members (23,779 online)
Click here to Skip to main content
Add your own
alternative version

Stats

40.8K views
358 downloads
29 bookmarked
Posted

Delete Links from the Recent Projects List on the Start Page of Visual Studio 2003, 2005 and 2008

, 25 Apr 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
This application deletes links from the Recent Projects list on the Start page of Visual Studio 2003/2005/2008
Screenshot - ssdrp.jpg

Introduction

This article describes how to delete links from the Recent Projects list in the Start page of Visual Studio 2003/2005/2008, by accessing registry keys and doing some operations like delete and changing them.

Background

Some time ago, I wanted to eliminate some links from the Recent Projects list and I did not know how to do that. Searching the Web, I found articles describing how to delete them, but they all described a manual process: Open Regedit from Run..., etc.... So, I decided to write a small application to automate this task.

The Code

The PopulateListView Method

You could use this application or source code in your own application.

The first method is used to populate a ListView in a Form.

private void PopulateListView(string versaoVS)
       {
           RegistryKey regKey = Registry.CurrentUser;
           regKey = regKey.OpenSubKey
               ("Software\\Microsoft\\VisualStudio\\" + versaoVS + "\\ProjectMRUList");
           lstvRecentProjects.Items.Clear();

           if (regKey == null) return;

           foreach (string keyname in regKey.GetValueNames())
           {
               try
               {
                   ListViewItem item = new ListViewItem();
                   item.Checked = false;
                   string kname = keyname;
                   string value = (String)regKey.GetValue(kname);
                   RegistryValueKind valuekind = regKey.GetValueKind(kname);

                   lstvRecentProjects.SmallImageList = imgList;

                   item.Text = ReturnTexto(value);
                   item.Tag = valuekind;
                   item.SubItems.Add(value);
                   item.ImageIndex = ReturnImageIndex(item.Text);

                   lstvRecentProjects.Items.Add(item);
                   lstvRecentProjects.Refresh();
               }
               catch (Exception ex)
               {
                   MessageBox.Show("Exception: " + ex.Message +
                       "\r\nPlease report this Exception, " +
                       "mail to carlosaraiva@gmail.com!", "Exception",
                       MessageBoxButtons.OK,
                       MessageBoxIcon.Error);
               }
           }
       }

The DeleteRegKey Method

You could use this application or source code in your own application. The second method is used to delete a registry key after selecting a project or solution in the ListView and clicking the Delete button.

private void DeleteRegKey()
       {
           string versaoVS = null;
           if (rdbVS2003.Checked)
               versaoVS = "7.1";

           if (rdbVS2005.Checked)
               versaoVS = "8.0";

           if (rdbVS2008.Checked)
               versaoVS = "9.0";

           try
           {
               RegistryKey regKey = Registry.CurrentUser;
               regKey = regKey.OpenSubKey("Software\\Microsoft\\VisualStudio\\" +
                        versaoVS + "\\ProjectMRUList", true);
               bool delete = false;
               string name = "File";

               if (regKey == null) return;

               foreach (ListViewItem item in lstvRecentProjects.Items)
               {
                   if (item.Checked)
                   {
                       delete = true;
                       lstvRecentProjects.Items.Remove(item);
                       foreach (string keyname in regKey.GetValueNames())
                       {
                           regKey.DeleteValue(keyname);
                       }
                   }
               }
               if (delete)
               {
                   lstvRecentProjects.Refresh();
                   foreach (ListViewItem item in lstvRecentProjects.Items)
                   {
                       int key = item.Index + 1;
                       string keyname = name + key.ToString();
                       regKey.SetValue(keyname, item.SubItems[1].Text,
                             (RegistryValueKind)item.Tag);
                   }
               }
           }
           catch (Exception ex)
           {
               MessageBox.Show("Exception: " + ex.Message +
                       "\r\nPlease report this Exception, " +
                       "mail to carlosaraiva@gmail.com!", "Exception",
                       MessageBoxButtons.OK,
                       MessageBoxIcon.Error);
           }
       }

History

  • 25th May, 2007: Initial post
  • 24th April, 2008: Article updated

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Carlos Saraiva Jr.
Software Developer
Brazil Brazil
Carlos Saraiva Jr. is a Developer and works with C#, VB.NET, Javascript, ASP.NET, WPF, WCF, SQL Server 2005/2008, Oracle, in a Web, Windows Forms, Windows Services using Visual Studio 2005/2008.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralMy vote of 5 Pin
Yusuf18-Feb-11 11:32
memberYusuf18-Feb-11 11:32 
GeneralMy vote of 1 Pin
zhaoxili8-Nov-09 23:18
memberzhaoxili8-Nov-09 23:18 
Generalthank you! Pin
gosiak15-Apr-09 4:43
membergosiak15-Apr-09 4:43 
GeneralExcellent - Some Minor Tweaks Pin
BobBoffin18-Mar-09 5:31
memberBobBoffin18-Mar-09 5:31 
GeneralExpress Editions Pin
DaveyM6930-Apr-08 6:14
memberDaveyM6930-Apr-08 6:14 
QuestionVS 2008 Pin
jackmos16-Dec-07 4:19
memberjackmos16-Dec-07 4:19 
GeneralRe: VS 2008 Pin
Carlos Saraiva Jr.24-Apr-08 4:13
memberCarlos Saraiva Jr.24-Apr-08 4:13 
GeneralThanks Pin
Ersin Ersoy17-Nov-07 8:47
memberErsin Ersoy17-Nov-07 8:47 
GeneralThanks Pin
ranunes3-Oct-07 1:19
memberranunes3-Oct-07 1:19 
GeneralThank You Pin
merlin98129-May-07 3:25
membermerlin98129-May-07 3:25 
GeneralThanks Pin
sides_dale25-May-07 18:23
membersides_dale25-May-07 18:23 
AnswerRe: Thanks Pin
sides_dale25-May-07 19:09
membersides_dale25-May-07 19:09 
AnswerRe: Thanks Pin
sides_dale25-May-07 19:39
membersides_dale25-May-07 19:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 25 Apr 2008
Article Copyright 2007 by Carlos Saraiva Jr.
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid