Click here to Skip to main content
Click here to Skip to main content

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

By , 25 Apr 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)

About the Author

Carlos Saraiva Jr.
Software Developer
Brazil Brazil
Member
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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberYusuf18 Feb '11 - 11:32 
Great Tool
GeneralMy vote of 1memberzhaoxili8 Nov '09 - 23:18 
thanks…………
Generalthank you!membergosiak15 Apr '09 - 4:43 
very cool solution!
GeneralExcellent - Some Minor TweaksmemberBobBoffin18 Mar '09 - 5:31 
I removed the right edge anchor from the buttons as they stretch under the list view if I make the window wider at run time.
 
I had a problem distinguishing between two projects with the same name but in different folders so I enabled ShowToolTips in the ListView and set the tooltip of each item to the full path returned from the registry.
 
I found that sometimes the value in the registry includes a suffix starting with a pipe character (|) followed by a GUID in curly brackets. This prevents the correct image being selected so I strip off anything following a pipe character (including the pipe character) before passing the value on to the rest of the code. This typically happens with .dtproj files and I also had it occur when using a .vbproj file with no .sln file.
 
There is no specific image to use with .dtproj files that I could find but it could be added to the image list if one can be found.
GeneralExpress EditionsmemberDaveyM6930 Apr '08 - 6:14 
Very cool code! Big Grin | :-D Thanks for sharing.
 
In case anyone else needs the info - the express editions are in the registry as follows
 
C# Express 2008: HKEY_CURRENT_USER\Software\Microsoft\VCSExpress\9.0\ProjectMRUList
C# Express 2005: HKEY_CURRENT_USER\Software\Microsoft\VCSExpress\8.0\ProjectMRUList
VB Express 2008: HKEY_CURRENT_USER\Software\Microsoft\VBExpress\9.0\ProjectMRUList
VB Express 2005: HKEY_CURRENT_USER\Software\Microsoft\VBExpress\8.0\ProjectMRUList
 
To make these work I had to obviously add new radio buttons, create the CheckChanged events for them and add new entries in the DeleteRegKey method. I also had to alter the way the versaoVS string is set in both the CheckChanged methods and DeleteRegKeyMethod so the VisualStudio part of the key was hard coded there and then remove that part of the key from the PopulateListView method.
QuestionVS 2008memberjackmos16 Dec '07 - 4:19 
Any chance of updating to include VS 2008?
GeneralRe: VS 2008memberCarlos Saraiva Jr.24 Apr '08 - 4:13 
Yeah... but in another article. I don't know why but I can't update this.
GeneralThanksmemberErsin Ersoy17 Nov '07 - 8:47 

Thanks !!!Suspicious | :suss:
GeneralThanksmemberranunes3 Oct '07 - 1:19 
Very useful! Laugh | :laugh:
Thanks.
 
sembug
GeneralThank Youmembermerlin98129 May '07 - 3:25 
Exactly what I need. This will save me a lot of time.
 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I get my developer tools from Merlin A.I. Soft

I get my news and jokes from Daily Roundup

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

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