Terminate a user request once it reached timeout (again)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beginlife
    New Member
    • Nov 2008
    • 4

    Terminate a user request once it reached timeout (again)

    Environment: C, C++, Dev-C++ using WinBGim ( this i can change to any window support flavour).

    < Read the place for keyboard interrupts ?? how>
    store last interrupt from keyboard.
    store current time
    while ( ! keyboard interrupt)
    {
    while ( (current time - stored time) < timeout);
    <kill application ?? how to abort window/console application?? SYSTEM(EXIT??)>

    }

    can anybody help me with references to look, example code for suitable calls please.. Even if i try to open another thread, i am not sure how to read the interrupts.. Did this in RTOS, by using RTOS calls.. it worked without i understanding it.. lol Can someone help me please ....
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    I have moved your post to its own thread; hijacking another thread is considered
    rude; don't do that anymore.

    Jos (moderator)

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Windows is not like an RTOS, in an RTOS you typically have direct access to all the platform hardware. In Windows you do not the programmer is separated from the hardware by the HAL (hardware abstraction layer). You can not (as far as I am aware) directly intercept an keyboard interrupts in Windows.

      Comment

      • beginlife
        New Member
        • Nov 2008
        • 4

        #4
        Sir,

        I see your point, but aren't there so many games and programs written to support windows to 1. To monitor the idle time, 2. To self destruct the application
        I am doing pretty simple application and i am seeing a failure as i not able to get this logic working. Tried with half heart to implement with delay() and exit but i have to leave this thought process after i realize that once function it will be executed unless i control with another action which is monitor keyboard.. Your alternate solution will be really help me to break the impass to proceed further... Many thanks in advance.

        Comment

        • arnaudk
          Contributor
          • Sep 2007
          • 425

          #5
          You can monitor the keyboard key states by periodically calling the GetAsyncKeyStat e() function in windows.

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            I see I think you may be able todowant ou want using the function SetWindowsHookE x (look it up on MSDN) to install a (or some) hook procedures to monitor keyboard/mouse activity, that couple with a timer (SetTimer or CreateWaitableT imer) should enable you to do what you want.

            Comment

            • beginlife
              New Member
              • Nov 2008
              • 4

              #7
              Originally posted by arnaudk
              You can monitor the keyboard key states by periodically calling the GetAsyncKeyStat e() function in windows.
              Thank you .. but unfortunately it checks for the key given as input.
              which is short GetAsyncKeyStat e( int KEY) it is time consuming to collect all the key codes and put a for or while loop as my program will be messy.
              Instead looking for function which returns if any key is pressed ...
              Any help will be really good. Also idea to terminate the window application or console through software on timer expiry Thanks a lot ...

              Comment

              • Banfa
                Recognized Expert Expert
                • Feb 2006
                • 9067

                #8
                Try reading post #6 again

                Comment

                • beginlife
                  New Member
                  • Nov 2008
                  • 4

                  #9
                  Originally posted by Banfa
                  Try reading post #6 again
                  Sir i read that, I will surely look to that issue and please accept my extreme gratitude for helping me. Unfortunately/Fortunately i am using Dev-C++ and i will let you know how it goes .. any other ideas i can try.

                  Regards
                  BL

                  Comment

                  • arnaudk
                    Contributor
                    • Sep 2007
                    • 425

                    #10
                    Dev-C++ hasn't been updated in 3 years. You might save yourself lots of trouble by using a more up-do-date compiler such as Visual C++ Express which is free and specifically designed for windows.

                    Comment

                    Working...