home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / classlib / desaware / vbpgutil.bas < prev   
Encoding:
BASIC Source File  |  1997-02-16  |  1.2 KB  |  40 lines

  1. Attribute VB_Name = "VBPGUtils"
  2. Option Explicit
  3. ' Copyright ⌐ 1997 by Desaware Inc. All Rights Reserved
  4.  
  5.  
  6. '
  7. ' Returns the difference in milliseconds between two FILETIME structures
  8. ' Note that very large time differences will break this code - it's intended
  9. ' to facilitate performance comparisons only.
  10. '
  11. Public Function FileTimeDifference(f1 As FILETIME, f2 As FILETIME) As Long
  12.     Dim low1&, low2&, carry&
  13.     ' First shift the low values
  14.     low1& = f1.dwLowDateTime \ 10000
  15.     low2& = f2.dwLowDateTime \ 10000
  16.     
  17.     ' If high values are equal, no overflow issues
  18.     If f1.dwHighDateTime = f2.dwHighDateTime Then
  19.         FileTimeDifference = low1& - low2&
  20.     Else
  21.         ' If we had an overflow, Add the "carry"
  22.         ' Each high field is 214748 milliseconds
  23.         carry& = f1.dwHighDateTime - f2.dwHighDateTime
  24.         FileTimeDifference = (low1& + 214748 * carry) - low2&
  25.     End If
  26. End Function
  27.  
  28. '
  29. ' Extracts a VB string from a buffer containing a null terminated
  30. ' string
  31. Public Function LPSTRToVBString$(ByVal s$)
  32.     Dim nullpos&
  33.     nullpos& = InStr(s$, Chr$(0))
  34.     If nullpos > 0 Then
  35.         LPSTRToVBString = Left$(s$, nullpos - 1)
  36.     Else
  37.         LPSTRToVBString = ""
  38.     End If
  39. End Function
  40.