Hi all,
This week I was trying to make a program which allows you to choose a particular set of programs to launch. A modified form of programs launching at start-up you could say. (For windows.)
I got stuck on a particular feature, namely a default set of programs if you do not choose anything within 10 seconds. (Sort of the same idea as a dual-boot screen.) After searching somewhat on the internet, I came to the conclusion I will not get it to work very easily.
I've got two questions about this, if the first question is answered false, we'll go on with the second.
First, this is the idea of my program:
int main calls a function wait_thread(), which eventually calls scanf() after some initialisation stuff. The function wait_thread() is by the way called in a new thread:
HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) wait_thread, NULL, 0, NULL);
Then, in the main thread, I wait for input or the 10 seconds to pass:
WaitForSingleObject(hThread, secs);
Where secs = 10000.
Two situations can occur:
1) Some input is given in scanf() and the program starts some programs, and eventually quits.
2) The 10 seconds have passed and the default set is started. Here the problems start to occur, because there is no normal way to shut down the created thread. If I do not do anything with the scanf()-thread, the scanf() still wants the input, and the thread doesn't quit until this input is given. When input is given, the program quits. When I call terminateThread():
TerminateThread(hThread, 0);
The program does not do anything any more after the last printf(). This printf(), by the way, is called after the terminateThread. The program sort of freezes.
Can anyone help me out of this?
If not, I got a second question, with which I do not need the scanf(), I think. I thought it might be a good idea to make something like the dual-boot screen, where you have to select some OS, and then press enter. You can navigate with your arrow keys, etc. Can something like this be made in C, and if so, what functions would I need?
Thanks in advance,
Marco
Oh by the way, the source is attached to this post. This is my first real program in C, so it can be sort of really badly written

. Sorry for the lot of commented code, it is just for testing, etc. If you come across something that looks like Dutch, that can be possible indeed

.