共用方式為


Add directories to the Add New Item dialog box

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

The following code example demonstrates how to register a new set of directories for the Add New Item dialog box. Directories for the Add New Item dialog box are different for each project. Therefore, the directories are registered under the Projects subkey, found in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0Exp\Projects.

Registry script

NoRemove Projects
{
  NoRemove %GUID_Project%
  {
    NoRemove AddItemTemplates
    {
      NoRemove TemplateDirs
      {
        ForceRemove %CLSID_Package%
        {
      ForceRemove /1 = s '#%Folder_Label_ResID%'
          {
            val TemplatesDir = s '%Template_Path%'
            val SortPriority = d 2000
          }
        }
      }
    }
  }
}

The %Template_Path% value specifies the full path of the directory that contains the project templates. These templates can be either .vsz files or prototypical template files to be cloned.

The SortPriority value specifies a sorting priority.

Add items to an existing project

You can also add items to an existing project. For example, for a Visual C# project, you can add items to the <root>\Program Files\Microsoft Visual Studio\VC#\CSharpProjectItems\LocalProjectItems folder. In this case, %GUID_Project% is the GUID for a C# project ({FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}).

You can also extend an existing project by programming a project subtype. With a project subtype, you can extend a project without writing a new project type. For more information about project subtypes, see Project subtypes.

See also