if your using this as a screensaver,
why not just simple have the code to display the pictures and remove everything else, save your program as "program.SCR" and let windows handle when it apears and disapears,
just put it with the other SCR files in window DIR, or manually select it.
im assuming windows 7 handles screen savers just like XP.