Results 1 to 3 of 3

Thread: How to use the following APIs

  1. #1

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562

    How to use the following APIs

    Code:
    Public Declare Function QueryPerformanceCounter Lib "kernel32" Alias "QueryPerformanceCounter" (lpPerformanceCount As LARGE_INTEGER) As Long
    
    Public Declare Function QueryPerformanceFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (lpFrequency As LARGE_INTEGER) As Long
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  2. #2
    Si_the_geek
    Guest
    go to http://www.allapi.net, and either look at their examples, or download the API-Guide which had definitions and examples for most API calls

  3. #3
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Declarations (as per yopur post)
    VB Code:
    1. Private Type LARGE_INTEGER
    2.    HiInt As Long
    3.    LoInt As Long
    4. End Type
    5.  
    6. Private Declare Function QueryPerformanceFrequency Lib "kernel32.dll" (lpFrequency As LARGE_INTEGER) As Long
    7. Private Declare Function QueryPerformanceCounter Lib "kernel32.dll" (lpFrequency As LARGE_INTEGER) As Long
    8.  
    9. 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:
    1. Public Property Get PerformanceCounter() As Currency
    2.  
    3. Dim lret As Long
    4. Dim lCounter As LARGE_INTEGER
    5.  
    6. lret = QueryPerformanceCounter(lCounter)
    7. If Err.LastDllError <> 0 Then
    8.     ReportError Err.LastDllError, "ApiSystem:PerformanceCounter", GetLastSystemError
    9. Else
    10.     PerformanceCounter = LargeIntToCurrency(lCounter)
    11. End If
    12.  
    13. End Property
    14.  
    15. Public Property Get PerformanceFrequency() As Currency
    16.  
    17. Dim lret As Long
    18. Dim lFrequency As LARGE_INTEGER
    19.  
    20. lret = QueryPerformanceFrequency(lFrequency)
    21. If Err.LastDllError <> 0 Then
    22.     ReportError Err.LastDllError, "ApiSystem:PerformanceFrequency", GetLastSystemError
    23. Else
    24.     PerformanceFrequency = LargeIntToCurrency(lFrequency)
    25. End If
    26.  
    27. End Property

    Utility function to convert LARGE_INTEGER...
    VB Code:
    1. Private Function LargeIntToCurrency(liInput As LARGE_INTEGER) As Currency
    2.     'copy 8 bytes from the large integer to an ampty currency
    3.     CopyMemory LargeIntToCurrency, liInput, LenB(liInput)
    4.     'adjust it
    5.     LargeIntToCurrency = LargeIntToCurrency * 10000
    6. End Function

    HTH,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width