-
Threading
Code:
#include <windows.h>
void main(){
while(1){
while(FindWindow("IEFrame", NULL));
MessageBox(0, "none", "", 0);
while(!FindWindow("IEFrame", NULL));
MessageBox(0, "one", "", 0);
}
}
I want to know if there are no IE windows open or if there is at
least one open. The code works, but it ties up 100% of my CPU
and also I want to be able to run other code while this code is
running.
I thought of creating a separate thread to run the code above
but will I still have the same problem with all the resources being
tied up?
-
You should set the thread you create to a low priority, then it doesn't hinder anyone from doing real work.
-
This may or may not be a valid suggestion, but wouldn't it be possible to create a system wide hook to look out for the WM_CREATE message? Then you could check through all open windows for the IE one, assuming a new window had been created...?
I have no idea how to do this... CornedBee? Any suggestions? :)
-
indeed, that should be possible. The problem is that a dll means a lot of additional work: writing a dll, searching the messages, installing the hook. And you have an additional file to distribute.
But since you are looking for the IE, isn't it possible to write an IE extension dll? This dll could search for YOUR app at creation and send it a message.