Okay, I'm not much of a programmer but I've DLed the sources and found that JKdefrag calls the function
The API reference ( http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx
) states that
Forces the system to be in the working state by resetting the system idle timer.
I think that by 'working state', it means that the computer doesn't enter some power saving mode, but could turn off the display. Maybe it somehow works in XP but doesn't in Vista. I think that issue can be fixed by calling
SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
This _should_ stop computer from entering sleep AND to prevent it from turning screen off.
BTW I noticed that you call this function everytime when you repaint the screen. The API has the ES_CONTINUOUS macro, which states that you want the current state to remain in effect, until you reset it. So, maybe you could achieve a better performance by calling
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED)
once somewhere early in the code and then calling
once before the termination of the program before it exits. I'll try to install Microsoft Visual C++ and try to test the changes myself.