这是给c++用的自动注释宏 在vs2008上测试通过

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值