vs2008 中加入注释宏

本文介绍如何使用VC宏功能实现快速添加文件及函数注释的过程。通过宏函数AddHeadDesc和AddMethodDesc,开发者可以在Visual C++环境中高效地为源代码添加标准化的头部注释和函数注释。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

1.注释宏函数定义,请修改DefaultUserName 为自己的姓名

    Sub AddHeadDesc()

        'DESCRIPTION: 添加一个标准的头文件说明

        DTE.ActiveDocument.Selection.StartOfDocument()

        DefaultUserName = "XXX"

        Dim FileName

        FileName = DTE.ActiveDocument.Name

        selection = DTE.ActiveDocument.Selection

 

        selection.Text = "/*******************************************************************" + CStr(CrLf)

        selection.Text = selection.Text + "文件名       :" + FileName + CStr(CrLf)

        selection.Text = selection.Text + "创建者       :" + DefaultUserName

        selection.Text = selection.Text + CStr(CrLf) + "创建时间   :" + CStr(Now)

        selection.Text = selection.Text + CStr(CrLf) + "功能描述   :"

        selection.Text = selection.Text + CStr(Lf) + "**              "

        selection.Text = selection.Text + CStr(Lf) + "******************************************************************/" + CStr(Lf)

        DTE.ActiveDocument.Selection.LineUp(flase, 3)

        DTE.ActiveDocument.Selection.EndOfLine()

    End Sub

 

    Sub AddMethodDesc()

        'DESCRIPTION: 添加函数注释

        Dim MethodName

        DefaultUserName = "helq"

        MethodName = DTE.ActiveDocument.Selection.Text

        DTE.ActiveDocument.Selection.StartOfLine()

        selection = DTE.ActiveDocument.Selection

        selection.Text = "/******************************************************************"

        selection.Text = selection.Text + CStr(CrLf) + "函数名       :" + MethodName

        selection.Text = selection.Text + "创建者       :" + DefaultUserName

        selection.Text = selection.Text + CStr(CrLf) + "参数       :"

        selection.Text = selection.Text + CStr(CrLf) + "返回值       :"

        selection.Text = selection.Text + CStr(CrLf) + "功能描述   :"

        selection.Text = selection.Text + CStr(CrLf) + "*              "

        selection.Text = selection.Text + CStr(CrLf) + "******************************************************************/" + CStr(CrLf)

 

        DTE.ActiveDocument.Selection.LineUp(flase, 5)

        DTE.ActiveDocument.Selection.EndOfLine()

    End Sub

 

2. 打开vc,工具菜单中选择  工具-〉宏->宏IDE

3. 宏ide,在资源管理器中选择sample->DevStudio6Editor ,把宏函数拷贝右侧编辑框中

4.回到vc 2008  ide,选择 工具->宏-〉宏资源管理器

   双击addheaddesc 添加文件描述

   选择函数名称,双击 addMethodDesc 添加函数描述

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值