将 .hpp 文件类型添加到 Visual Studio

问题描述:

默认情况下,Visual Studio 在创建新类时仅支持包含 .h 或 .cpp 文件.不过,我知道我可以轻松选择 .h 并将其重命名为 .hpp 以实现我正在寻找的新扩展名.但是,我想为此列表创建一个新的模板文件类型,将 .hpp 文件显示为一个选项,以便我可以轻松地从 .h 和 .cpp 文件列表中选择这样的文件.这是 Visual Studio 文件选择器的图片:

By default, Visual Studio only supports the inclusion of either a .h or .cpp file when creating a new class. I understand, though, that I can easily choose .h and rename it to .hpp to achieve the new extension that I am looking for. However, I would like to create a new template file type for this list showing .hpp files as an option so that I can easily choose such a file from the list of .h and .cpp files. Here is a picture of the visual studio file chooser:

添加新的 .hpp 文件类型的最佳方法是什么?

What is the best way to add my new .hpp file type?

我找到了一种快速而肮脏的方法来完成此任务;其实很简单.只需在 Notepad++ 中创建一个空白的 .hpp 文件(这样您就可以获得正确的扩展名和内容),然后将其直接放入此文件夹中:

I found a quick and dirty way to accomplish this; it is actually quite simple. Just create a blank .hpp file in Notepad++(So you get the correct extensions and stuff) and then drop it right into this folder:

它看起来不像其他的那么漂亮,因为它们显然是从其他地方提取信息来重命名文件......但它有效!

It doesnt look as pretty as the other ones, because they are apparently pulling information from somewhere else to rename the files...but it works!

这是成品的样子(不知道黑色图标从何而来)

Here is what the finished product looks like(No Idea where the black icon came from)