A screensaver is a windows executable with some minor changes
to be made the code. The screensaver is an executable with the extension
.scr. It should be located in your windows \ system32 folder for the Windows
O/S to recognize it in the screensaver property window.
When the screensaver is invoked by Windows O/S , it sends some additional
command line parameters that we need to check in the code. Some of the
options are
/p
Preview
Mode
/c:
Config
Mode
/s
ScreenSaver
mode
When the screensaver is selected in the properties window , the Windows
OS returns an additional parameter which is the handle to the small computer
screen in the properties window. This is in case you want to display smaller
size preview of your screensaver.eg : <screensaver.scr> /p xxxx
( where xxxx is the window handle ). You can reterive the Graphics object
associated with the handle to do your drawing and painting
parent = IntPtr.Zero;
if ( cmdList[1] == "/p" )// Options
parent = (IntPtr) uint.Parse(cmdList[2]);
if (GetClientRect(parent, ref rc))
{
Graphics g = Graphics.FromHwnd(parent);
}