如何得到应用程序的运行时间

来源:互联网 发布:浙江省网络图书馆 编辑:程序博客网 时间:2024/04/30 05:53
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

 

利用函数GetTickCount就可以搞定,不过他是个API,需要声明一下下。
还有需要注意的是,这个函数返回的是毫秒,所以需要自己再转换单位的!
GetTickCount得到的是操作系统到现在为止的运行时间,那么用两次的返回值相减就可以了。

Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim a As Long

Private Sub Command1_Click()
MsgBox (GetTickCount - a) '应用程序运行时间
End Sub

Private Sub Form_Load()
a = GetTickCount
End Sub

由于GetTickCount返回的值是DWORD类型。因此,操作系统再运行了49.7天后,这个值就会归0。

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击