Visual Studio 2005為C++ .h頭添加檔案說明的巨集

這些巨集腳本基本出自網上,本人只是略加修改,出處已無從考證,見諒!

  1. Imports System
  2. Imports EnvDTE
  3. Imports EnvDTE80
  4. Imports System.Diagnostics
  5. Public Module GenerateComment
  6.     '插入文件头的说明(简体中文)
  7.     Sub ClassHeaderCN()
  8.         Dim doc As Document = DTE.ActiveDocument
  9.         Dim docText As TextDocument = doc.Object
  10.         Dim curText As TextSelection = docText.Selection
  11.         'Go to the header of the text
  12.         curText.GotoLine(1)
  13.         Dim strText As String
  14.         strText = "/" + vbCrLf
  15.         strText += "// 文 件 名:" + vbTab + doc.Name + vbCrLf
  16.         strText += "// 功能描述:" + vbTab + vbCrLf
  17.         strText += "// 编 写 人:" + vbTab + vbCrLf
  18.         strText += "// 编写日期:" + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbCrLf
  19.         strText += "// 修    改:" + vbTab + vbCrLf
  20.         strText += "// 修 改 人:" + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbTab + "<建立>" + vbCrLf
  21.         strText += "// 备    注:" + vbTab + vbCrLf
  22.         strText += "/" + vbCrLf
  23.         curText.Insert(strText)
  24.     End Sub
  25.     '插入文件头的说明(English)
  26.     Sub ClassHeaderEN()
  27.         Dim doc As Document = DTE.ActiveDocument
  28.         Dim docText As TextDocument = doc.Object
  29.         Dim curText As TextSelection = docText.Selection
  30.         'Go to the header of the text
  31.         curText.GotoLine(1)
  32.         Dim strText As String
  33.         strText = "/" + vbCrLf
  34.         strText += "//FileName:" + vbTab + doc.Name + vbCrLf
  35.         strText += "//Function: " + vbTab + vbCrLf
  36.         strText += "//Author: " + vbTab + vbCrLf
  37.         strText += "//Date: " + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbCrLf
  38.         strText += "//Modify: " + vbTab + vbCrLf
  39.         strText += "//Editor: " + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbTab + "<Create>" + vbCrLf
  40.         strText += "//Memo: " + vbTab + vbCrLf
  41.         strText += "/" + vbCrLf
  42.         curText.Insert(strText)
  43.     End Sub
  44.     '编辑文件时修改文件头(简体中文)
  45.     Sub AddModificationCN()
  46.         Dim doc As Document = DTE.ActiveDocument
  47.         Dim docText As TextDocument = doc.Object
  48.         Dim curText As TextSelection = docText.Selection
  49.         curText.GotoLine(7)
  50.         Dim strText As String
  51.         strText = "// 修 改 人:" + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbTab + "<编辑>" + vbCrLf
  52.         curText.Insert(strText)
  53.     End Sub
  54.     '编辑文件时修改文件头(English)
  55.     Sub AddModificationEN()
  56.         Dim doc As Document = DTE.ActiveDocument
  57.         Dim docText As TextDocument = doc.Object
  58.         Dim curText As TextSelection = docText.Selection
  59.         curText.GotoLine(7)
  60.         Dim strText As String
  61.         strText = "//Editor: " + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbTab + "<Edit>" + vbCrLf
  62.         curText.Insert(strText)
  63.     End Sub
  64.     '在函数前添加注释(简体中文)
  65.     Sub FunctionCommentCN()
  66.         Dim doc As Document = DTE.ActiveDocument
  67.         Dim docText As TextDocument = doc.Object
  68.         Dim curText As TextSelection = docText.Selection()
  69.         Dim strText As String
  70.         strText = "/" + vbCrLf
  71.         strText += "//功能:" + vbCrLf
  72.         strText += "//作者:" + vbCrLf
  73.         strText += "//日期:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbCrLf
  74.         strText += "//参数:" + vbCrLf
  75.         strText += "//返回:" + vbCrLf
  76.         strText += "/"
  77.         curText.Insert(strText)
  78.     End Sub
  79.     '在函数前添加注释(English)
  80.     Sub FunctionCommentEN()
  81.         Dim doc As Document = DTE.ActiveDocument
  82.         Dim docText As TextDocument = doc.Object
  83.         Dim curText As TextSelection = docText.Selection()
  84.         Dim strText As String
  85.         strText = "/" + vbCrLf
  86.         strText += "//Function: " + vbTab + vbCrLf
  87.         strText += "//Author: " + vbTab + vbCrLf
  88.         strText += "//Date: " + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbCrLf
  89.         strText += "//Params: " + vbTab + vbCrLf
  90.         strText += "//Return: " + vbTab + vbCrLf
  91.         strText += "/"
  92.         curText.Insert(strText)
  93.     End Sub
  94. End Module


 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值