Screen program protection?

Would it be possible to write a program that monotors the monitor power state? (on or off) And if possible, if the screen is turned off at the power button and the power is turend back again that the pc will shut itself down unless you turned on the power twice in a row within 5 seconds?

Yea, you can do this but you need to have access to the hardware so that you can check whether or not the computer is sending stuff to the monitor or if the power button is toggled. Then you need to be able to legitimately shut down the computer with your program, this also requires some kind of low level control.