Declarations (as per yopur post)
VB Code:
Private Type LARGE_INTEGER
HiInt As Long
LoInt As Long
End Type
Private Declare Function QueryPerformanceFrequency Lib "kernel32.dll" (lpFrequency As LARGE_INTEGER) As Long
Private Declare Function QueryPerformanceCounter Lib "kernel32.dll" (lpFrequency As LARGE_INTEGER) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Use (as per ApiSystem.PerformanceCounter)
VB Code:
Public Property Get PerformanceCounter() As Currency
Dim lret As Long
Dim lCounter As LARGE_INTEGER
lret = QueryPerformanceCounter(lCounter)
If Err.LastDllError <> 0 Then
ReportError Err.LastDllError, "ApiSystem:PerformanceCounter", GetLastSystemError
Else
PerformanceCounter = LargeIntToCurrency(lCounter)
End If
End Property
Public Property Get PerformanceFrequency() As Currency
Dim lret As Long
Dim lFrequency As LARGE_INTEGER
lret = QueryPerformanceFrequency(lFrequency)
If Err.LastDllError <> 0 Then
ReportError Err.LastDllError, "ApiSystem:PerformanceFrequency", GetLastSystemError
Else
PerformanceFrequency = LargeIntToCurrency(lFrequency)
End If
End Property
Utility function to convert LARGE_INTEGER...
VB Code:
Private Function LargeIntToCurrency(liInput As LARGE_INTEGER) As Currency
'copy 8 bytes from the large integer to an ampty currency
CopyMemory LargeIntToCurrency, liInput, LenB(liInput)
'adjust it
LargeIntToCurrency = LargeIntToCurrency * 10000
End Function
HTH,
Duncan