请问各位呀............
怎么用VB编一个获取开机时间的程序,还有计算开了多长了.............
系统启动后自动调用程序
程序内容:获取系统当前时间,并从此刻开始计时
Private Declare Function GetTickCount Lib "kernel32" () As Long '用于获取自windows启动以来经历的时间长度(毫秒)
Private Sub Timer1_Timer()
Dim hour As Long
Dim minute As Long
Dim intSecond As Integer
Dim strHour As String
Dim strMinute As String
Dim strSecond As String
hour = GetTickCount \ 1000 \ 60 \ 60
strHour = Str$(hour) + "小时"
minute = (GetTickCount - hour * 60 * 60 * 1000) \ 1000 \ 60
strMinute = Str$(minute) + "分钟"
intSecond = (GetTickCount - Val(strHour) * 60 * 60 * 1000 - Val(strMinute) * 60 * 1000) \ 1000
strSecond = Str$(intSecond) + "秒钟"
MsgBox strHour & strMinute & strSecond
End Sub
谢谢了,在这里真的学到很多呀
Private Declare Function GetTickCount Lib "kernel32" () As Long '用于获取自windows启动以来经历的时间长度(毫秒)
Private Sub Timer1_Timer()
Dim hour As Long
Dim minute As Long
Dim intSecond As Integer
Dim strHour As String
Dim strMinute As String
Dim strSecond As String
hour = GetTickCount \ 1000 \ 60 \ 60
strHour = Str$(hour) + "小时"
minute = (GetTickCount - hour * 60 * 60 * 1000) \ 1000 \ 60
strMinute = Str$(minute) + "分钟"
intSecond = (GetTickCount - Val(strHour) * 60 * 60 * 1000 - Val(strMinute) * 60 * 1000) \ 1000
strSecond = Str$(intSecond) + "秒钟"
MsgBox strHour & strMinute & strSecond
end '这边想再加一个
End Sub
[此贴子已经被作者于2007-8-20 21:26:05编辑过]