By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,434 Members | 1,858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,434 IT Pros & Developers. It's quick & easy.

Terminate a user request once it reached timeout (again)

P: 4
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 ....
Nov 6 '08 #1
Share this Question
Share on Google+
9 Replies

Expert 10K+
P: 11,448
I have moved your post to its own thread; hijacking another thread is considered
rude; don't do that anymore.

Jos (moderator)
Nov 6 '08 #2

Expert Mod 5K+
P: 8,916
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.
Nov 6 '08 #3

P: 4

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.
Nov 7 '08 #4

P: 424
You can monitor the keyboard key states by periodically calling the GetAsyncKeyState() function in windows.
Nov 7 '08 #5

Expert Mod 5K+
P: 8,916
I see I think you may be able todowant ou want using the function SetWindowsHookEx (look it up on MSDN) to install a (or some) hook procedures to monitor keyboard/mouse activity, that couple with a timer (SetTimer or CreateWaitableTimer) should enable you to do what you want.
Nov 7 '08 #6

P: 4
You can monitor the keyboard key states by periodically calling the GetAsyncKeyState() function in windows.
Thank you .. but unfortunately it checks for the key given as input.
which is short GetAsyncKeyState( 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 ...
Nov 9 '08 #7

Expert Mod 5K+
P: 8,916
Try reading post #6 again
Nov 10 '08 #8

P: 4
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.

Nov 10 '08 #9

P: 424
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.
Nov 10 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.