Announcement

Collapse

Maintenance

The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

GetCurrentTime ???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GetCurrentTime ???

    Hello...
    I am Using PBDLL.50 and i like to eliminate unwanted messages from the message queue by comparing GetMessageTime with the current time.
    Charles Petzold's GetCurrentTime doesn't work !
    I neeed to know the current system time!..who can help..it is important for me..

    Thanks..Michael



    [This message has been edited by Michael Rosner (edited July 08, 2000).]

  • #2
    GetCurrentTime was in 16-bit versions of Windows and was replaced by GetTickCount.
    But better to use QueryPerformanceFrequency / QueryPerformanceCounter
    (search BBS by these words; there are samples)


    ------------------

    Comment


    • #3
      You want that in SYSTEMTIME structure?

      Now you have a systemtime structure.

      But for what you are doing, you may want something a bit more accurate:
      You may have to peel this code apart a bit but it should server your purpose in nanoseconds.


      Thanks to a lot of people for this help when I needed it:
      I'm just generating this as I go along, so please debug.

      Code:
      Union QuadFILETIME
        dwLowDateTime  As Dword
        dwHighDateTime As Dword
        qdTime         As Quad
      End Union   
      '
      '
      '
      Function IsTimeGreaterThan(ot as SYSTEMTIME) As Long
      'ot will be the systemtime of the time the message came in ??
      'If so we can just compare to current time.
      
      Dim QT          As QuadFILETIME
      Dim QT2         As QuadFILETIME
      Dim st          As SYSTEMTIME
      
      GetSystemTime st   'GMT Time! Current time
      
      '
      'Convert to QUAD time
      SystemTimeToFileTime ST,QT
      SystemTimeToFileTime ot,QT2
      If QT > QT2 Then
          MsgBox "The current time is greater than the message time"
      End If
      End Function

      ------------------
      Scott
      mailto:[email protected][email protected]</A>
      MCSE, MCP+Internet
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        Time$ ?


        ------------------
        [email protected]
        hellobasic

        Comment


        • #5
          The time-member in MSG-structure is in DWORD format.
          This indicate that the MSG.time is the elapsed time in milliseconds since
          Windows was restarted. After 47.9 days (approx) this will wrap around and start at zero again.
          You would use GetTickCount to get the "current time" in milliseconds
          Code:
           %Time_Limit = 5000  '( 5000 milliseconds)
           dwNow = GetTickCount
           If dwNow < MSG.time then
            ..Calculate new time as wraparound has accured
           Else
            If (dwNow - MSG.time) > %Time_limit Then
             .. take timed_out action
            Else
             .. take other action 
            End if
           End if

          ------------------
          Fred
          mailto:[email protected][email protected]</A>
          http://www.oxenby.se

          Fred
          mailto:[email protected][email protected]</A>
          http://www.oxenby.se

          Comment


          • #6
            If I had read your message carefully, I'ld have seen that you use
            GetMessageTime api-call.
            If you look this message up in MSDN (or help) you will find that
            GetTickCount is the way to do it.



            ------------------
            Fred
            mailto:[email protected][email protected]</A>
            http://www.oxenby.se

            Fred
            mailto:[email protected][email protected]</A>
            http://www.oxenby.se

            Comment


            • #7
              Hello...

              Tank you all for your help.
              The "GetTickCounter" was exactly what i was looking for.
              Now it works fine..

              Best regards..Michael Rosner

              ------------------


              [This message has been edited by Michael Rosner (edited July 09, 2000).]

              Comment

              Working...
              X