Announcement

Collapse
No announcement yet.

Timer in a DLL

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

  • Timer in a DLL

    So my DLL is activated, keyboard hook set.

    Can i set a timer in Libmain? How would one do this if not?


    Scott


    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    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

  • #2
    Timer works fine in DLL (if there is message loop somewhere - for example, in Exe).
    Start a timer by hTimer = SetTimer (%HWND_DESKTOP, ..., ..., CodePtr(TimerProc)) and process events in
    Code:
    Function TimerProc(ByVal hwnd As Long, ByVal wMsg As Long, idEvent As Dword Ptr,  ByVal dwTime As Dword) As Long
       ...
       Function = %True
    End Function
    ------------------
    E-MAIL: [email protected]

    Comment


    • #3
      Hate to bring this up again, almost there...

      Here's my functions, question is what type of events am I looking for in this TimerProc, same as any other dialog message pump???
      Will my modification work? (Very hard to test this right now)

      Code:
      Function InitializeCCSDLL() Export As Long
      g_hTimer = SetTimer(%HWND_DESKTOP, %IDT_TIMER1,  30000, ByVal CodePtr(TimerProc))
      Function = %TRUE
      End Function
      '------------------------------------------------------------------------------------------------------------------------
      Function TimerProc(ByVal hwnd As Long, ByVal wMsg As Long,ByVal wParam As Long, ByVal lParam As Long) As Long
      'Function TimerProc(ByVal hwnd As Long, ByVal wMsg As Long, idEvent As Dword Ptr,  ByVal dwTime As Dword) As Long
      Select Case wMsg
          Case %WM_TIMER
              Select Case Wparam
                Case %IDT_TIMER1
      '               Check for Time here, must be 2 or 3 am, if sendmail fails set timer again
      '               SendMail
                      KillTimer %HWND_DESKTOP, %IDT_TIMER1
              End Select
      End Select
      End Function
      
      
      Now this is how I normally use a timer, same thing?
      
      Scott
      
      
          Case %WM_TIMER
              Select Case CbWparam
                Case %IDT_TIMER1
                   MousePtr 0
                   Dialog End sDlg, 1
              End Select

      ------------------
      Scott
      mailto:[email protected][email protected]</A>

      [This message has been edited by Scott Turchin (edited December 13, 2000).]
      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
        Also, this timer may solve another issue, can someone confirm this?

        If an EXE runs a DLL Function called Init, etc, and that function starts a timer, the EXE doesn't need a message pump or a WaitForSingleObject does it?
        Seems that on my machine the timer is holding the instance of the DLL open so to speak (PB/DLL says Destination Write File Error so I assume so)..


        Kill two bugs with one stone ????


        Scott

        ------------------
        Scott
        mailto:[email protected][email protected]</A>
        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


        • #5
          Scott, have a look at "SetTimer" in MSDN
          ..or by specifying a TimerProc callback function when creating the timer.
          When you specify a TimerProc callback function, the default window procedure
          calls the callback function when it processes WM_TIMER.
          Therefore, you need to dispatch messages in the calling thread,
          even when you use TimerProc instead of processing WM_TIMER.

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



          [This message has been edited by Fred Oxenby (edited December 13, 2000).]
          Fred
          mailto:[email protected][email protected]</A>
          http://www.oxenby.se

          Comment

          Working...
          X