Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module Module1
Public Sub AddClassComment()
'定义选择区域
Dim DocSel As EnvDTE.TextSelection
Dim tmpStrArr As String()
'初始化选择区域是当前文档的选择
DocSel = DTE.ActiveDocument.Selection
'选择区域移动到文档的开头
DocSel.StartOfDocument()
DocSel.Text = "/*******************************************************************"
DocSel.NewLine()
DocSel.Text = "* Copyright (C) abc Corporation"
DocSel.NewLine()
DocSel.Text = "* All rights reserved."
DocSel.NewLine()
DocSel.Text = "*"
DocSel.NewLine()
DocSel.Text = "*Author: zmy (zmy12006@hotmail.com)"
DocSel.NewLine()
DocSel.Text = "*Create Date:" + DateTime.Now.ToString()
DocSel.NewLine()
DocSel.Text = "*FileName:" + DTE.ActiveDocument.Name
DocSel.NewLine()
DocSel.Text = "*Description:"
DocSel.NewLine()
DocSel.Text = "*"
DocSel.NewLine()
DocSel.Text = "* Date Author Description"
DocSel.NewLine()
DocSel.Text = "*" + DateTime.Now.ToString() + " zmy" + " Added"
DocSel.NewLine()
DocSel.Text = "*******************************************************************/"
'Extend function
tmpStrArr = DTE.ActiveDocument.Name.Split(".".ToCharArray())
If tmpStrArr.Length = 2 Then
If tmpStrArr(1).ToLower() = "h" Then
DocSel.NewLine()
DocSel.Text = "#ifndef " + tmpStrArr(0).ToUpper() + "_" + tmpStrArr(1).ToUpper() + "_"
DocSel.NewLine()
DocSel.Text = "#define " + tmpStrArr(0).ToUpper() + "_" + tmpStrArr(1).ToUpper() + "_"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endif //" + tmpStrArr(0).ToUpper() + "_" + tmpStrArr(1).ToUpper() + "_"
ElseIf tmpStrArr(1).ToLower() = "cpp" Then
DocSel.NewLine()
DocSel.Text = "#include""" + tmpStrArr(0) + ".h"""
DocSel.NewLine()
End If
End If
DocSel.NewLine()
End Sub
End Module