Home » Windows API

GetTickCount

說明:
GetTickCount 函式可取得系統啟動至今的毫秒數


引用函式庫:
Kernel32


適用系統:
Windows NT 3.1 或 Windows 95以上


函式原型:

Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" ( _
    ) As Long



參數型態及說明:


回傳值:
Long 呼叫成功的話,將會回傳系統啟動至今的毫秒數

.NET Framework API:
System.Environment.TickCount


VB範例:

檢視原始碼 Visual Basic
1
2
3
4
5
6
7
8
'VB的宣告
Private Declare Function GetTickCount Lib "kernel32" ( _
	) As Long
 
Dim rtvl As Long
 
'取得系統啟動至今的毫秒數
rtvl = GetTickCount()

RB範例:

檢視原始碼 REALBasic
1
2
3
4
5
6
7
8
'RB的宣告
Declare Function GetTickCount Lib "kernel32" ( _
	) As Integer
 
Dim rtvl As Integer
 
'取得系統啟動至今的毫秒數
rtvl = GetTickCount()

VB.NET範例:

1
2
3
4
5
6
7
8
9
10
'VB.NET的宣告
<DllImport("kernel32.dll")> _
Shared Function GetTickCount( _
	) As UInteger
End Function
 
Dim rtvl As UInteger
 
'取得系統啟動至今的毫秒數
rtvl = GetTickCount()

C#範例:

1
2
3
4
5
6
7
8
9
//C#的宣告
[DllImport("kernel32")]
public static extern uint GetTickCount(
	);
 
uint rtvl;
 
//取得系統啟動至今的毫秒數
rtvl = GetTickCount();

發表迴響