First, I would like to recommend instead a message box, two buttons "Pause" and "Stop" in your main dialog.
Perform the registry scanning in a worker thread. When press "Pause", call SuspendThread dunction in order to suspend registry scanning and change the button caption from "Pause" to "Resume". When the user press "Resume", call ResumeThread to start scanning again.
When the user press "Stop" you can call TerminateThread.
I prefer using a loop that you can fully control instead of killing the thread with terminate thread. The reason is if you want to make some 'clean-up' after the loop (ok, maybe infinite loop was not the right word but I meant a loop that finishes when one of the condition is met).
First when say "maybe infinite loop was not the right" because registry is a finite stuff and sooner or later its scanning have to finish, regardless the user pushes "Stop" or not.
Second, indeed for the sake of good recommendations we have to avoid TerminateThread, which in our case can let a registry key open for reading which can lead in unpredictable, catastrophic effects.
Using SuspendThread() and TerminateThread() is very risky, and not nearly as simple as you've described here. Before a thread suspends itself, it needs to ensure that by being suspended, the calling thread is not affected. If a synchronization object is being held by the thread, it would need to be released. Suspending a thread from another, without taking all of the precautions, is not a good idea because the thread being suspended might be in the middle of something important (e.g., memory allocation). This could result in your application entering a "hung" state. If a thread calls TerminateThread() on itself, there is no chance for cleanup. The thread goes away right then and there.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
i am a new programer in mfc.now i met a problem.I want to draw objects such as line ,rectagle,stroke etc. and need these objects can be resize,move,rotate in interactive mode which means using track handles of interation with mouse.I can realize resize and move with CRectTacker and it works well.But the CRectTracker do not support rotate.Now i want to rotated these objcets. i can draw rotated objects in "GDI+" ,but not in the realtime mode.if someone have realize it , i will thanks for your helping in advance.Please give me some advice.i could not find some topics about this.
I'll try to be a little more precise. The serialnumber isn't as such displayed on the monitor screen ( if thats what You mean ). It's more a question to get the monitor to tell its serial number. I have perviously seen a program, that could do that. So some interaction between the monitor an the CPU unit may be possible. At least - it seems - some monitors are capable of doing that. Perhaps in conjunction with "non standard" videoports. For instance the new digital porttypes.
I was using sendmesage function to a window in my DLL which is attached to other application using windows hook, mainly to get text from a control.
sendmessage(hwnd,WM_GETTEXT,(wparam)100,(lparam)sztext); To my surprise sendmessage was not able to retrieve text in sztext.
could the problem lies in the creator of application who has not properly written code in WM_GETTEXT case. I think he/she may not have written appropriate code to provide proper response when send message function with WM_GETTEXT is called.
Am I wrong in analysing
please reply if u have encountered a problem like this before
Last Visit: 31-Dec-99 18:00 Last Update: 13-May-21 10:09