GetTickCount函数
函数功能:GetTickCount返回(retrieve)从操作系统启动到现在所经过(elapsed)的毫秒数,它的返回值是DWORD。
函数原型:
DWORD GetTickCount(void);
VB版
VB声明:
Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
例如:实现延时
Public Sub Sleep(numa As Long)
Dim num1 As Long
Dim num2 As Long
Dim numb As Long
numb = 0
num1 = GetTickCount
Do While numa - numb > 0
num2 = GetTickCount
numb = num2 - num1
DoEvents
Loop
End Sub
C++版
CString s;
DWORD k=::GetTickCount(); //获取毫秒级数目
int hm=k/3600000; //hm为小时数
int ms=(k-3600000*hm)/60000; //ms为分钟数
int se=(k-3600000*hm-60000*ms)/1000; //se为秒数(除以1000是因为k精确到毫秒)
s.Format("%d:%d:%d",hm,ms,se); //输出时、分、秒
库文件:kernl32.dll
C/C++头文件:winbase.h
函数功能:GetTickCount返回(retrieve)从操作系统启动到现在所经过(elapsed)的毫秒数,它的返回值是DWORD。
函数原型:
DWORD GetTickCount(void);
VB版
VB声明:
Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
例如:实现延时
Public Sub Sleep(numa As Long)
Dim num1 As Long
Dim num2 As Long
Dim numb As Long
numb = 0
num1 = GetTickCount
Do While numa - numb > 0
num2 = GetTickCount
numb = num2 - num1
DoEvents
Loop
End Sub
C++版
CString s;
DWORD k=::GetTickCount(); //获取毫秒级数目
int hm=k/3600000; //hm为小时数
int ms=(k-3600000*hm)/60000; //ms为分钟数
int se=(k-3600000*hm-60000*ms)/1000; //se为秒数(除以1000是因为k精确到毫秒)
s.Format("%d:%d:%d",hm,ms,se); //输出时、分、秒
库文件:kernl32.dll
C/C++头文件:winbase.h