构建时长宏





5.00/5 (2投票s)
2001年10月2日

56778
一个显示项目构建时长的 DevStudio 宏
引言
这个宏为DevStudio6添加了一个缺失的功能。它会显示项目构建时长。你会在输出窗口中看到一个新的标签页,名为宏(位于标准标签页旁边:构建、调试、在文件中查找...)。
打开你的宏文件,在任何其他函数或子程序之前插入以下行。
Public dBuildStartTime
接下来,将下面的代码放置在你的宏文件中的某个位置。这些事件(Application_BeforeBuildStart
和 Application_BuildFinish
)将在你构建项目时被 DevStudio 自动触发。
Sub Application_BeforeBuildStart() ' keep the build-starting time dBuildStartTime = Now Application.PrintToOutputWindow " " Application.PrintToOutputWindow "--------------------------------" Application.PrintToOutputWindow "Build start: " & dBuildStartTime End Sub Sub Application_BuildFinish(nNumErrors, nNumWarnings) ' get build time dNow = Now sec = DateDiff("s", dBuildStartTime, dNow) hours = sec \ 3600 sec = sec - hours * 3600 min = sec \ 60 sec = sec - min * 60 ' format Dim strH, strM, strS If hours > 10 Then strH = hours Else strH = "0" & hours End If If min > 10 Then strM = min Else strM = "0" & min End If If sec > 10 Then strS = sec Else strS = "0" & sec End If ' display Application.PrintToOutputWindow "Build end: " & dNow Application.PrintToOutputWindow "Build time: " & strH & ":" & strM & ":" & strS Application.PrintToOutputWindow nNumWarnings & " warning(s), " & nNumErrors & " error(s)." End Sub