查看: 14  |  回复: 0
  VB6 利用Api函数计算Windows从启动后所运行的总时间
楼主
发表于 昨天 23:08

新建From1(窗体),新建Command1(按钮CommandButton),代码:

Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Sub Command1_Click()
    Dim hour As Long
    Dim minute As Long
    hour = GetTickCount \ 1000 \ 60 \ 60
    Debug.Print Str(hour) + "小时"

    minute = (GetTickCount - hour * 60 * 60 * 1000) \ 1000 \ 60
    Debug.Print Str(minute) + "分钟"
End Sub

运行结果:

 7小时
 58分钟


您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2024 MaNongKu.com