问题
I want to write a screen saver for Windows using the Windows API. How can I start to write it?
回答1:
Basically a screensaver is just a normal application that accepts a few command line options, provided by windows, to determine if it should start fullscreen or in a preview window.
So, write a normal exe-application that takes the following command line arguments (from http://msdn.microsoft.com/en-us/library/ms686421(v=vs.85).aspx):
- /s – Start the screensaver in full-screen mode.
- /c – Show the configuration settings dialog box.
- /p #### – Display a preview of the screensaver using the specified window handle.
Next check out some DirectX / OpenGL / SDL tutorials and write some eye candy.
Obviously you should check for mouse movements and key presses and exit your application if the user wakes up.
回答2:
Good luck on your search.
Its better if you can find real screensaver code instead of hacking up something. This way you can work on the screensaver faster.
There is more to screensavers than just modified exes. Do you want dual monitor support? How would you do it? Both screens as one big screen or both screens as separate screens?
Opengl does things a bit differently and there are other issues.
Microsoft had demo code for opengl and directx screensavers, if you want I can find the names because I might have the code on my computer somewhere. Could make your search easier with some project names.
来源:https://stackoverflow.com/questions/5165133/how-can-i-write-a-screen-saver-for-windows-in-c