Click here to Skip to main content
15,072,933 members
Articles / Containers / Virtual Machine
Posted 14 Jan 2004


43 bookmarked

Windows Virtual Machine screen saver

Rate me:
Please Sign up or sign in to vote.
3.38/5 (17 votes)
20 Jan 20043 min read
A Windows version of a cool Linux screen saver.



I once saw a really cool Linux screen saver while working in the Linux labs at school. It had a bunch of colored numbers and letters all over the screen which periodically pulsed and changed. I could tell it was some kind of program interpreter and that the cycling pulses were running code, but beyond that I didn't have a clue.

Some time later (and not too long ago), I had the urge to write a similar screen saver. My friend shot down my ideas one by one and then suggested I do a port of the original Linux screen saver. That's precisely what I've done.

The Windows Virtual Machine (WVM) screen saver is distributed under the GNU General Public License (GPL). It requires at least Windows NT 4.0 and DirectX 8.0 to run. The source code is provided in Visual C++ 6.0 format. The original screen saver was written by Artur Rataj and is called KVM.

Getting Started

If you want to get the screen saver up and running, extract wvm.scr to your system directory (probably C:\WINDOWS\SYSTEM32). Then right-click on the Desktop, select Properties, and click on the Screen Saver tab. Select the Virtual Machine screen saver from the list. You can now click Settings to change the simulation parameters, click Test to see the screen saver, and click OK to set this as your screen saver.

For details on what the screen saver actually does, click on Help in the Settings dialog. There's a rather exhaustive explanation from the user's perspective there. What follows is an overview from the programmer's perspective.


The screen saver is divided into four main modules:

  • Display.cpp / Display.h
  • ScreenSaver.cpp / ScreenSaver.h
  • Settings.cpp / Settings.h
  • Simulator.cpp / Simulator.h


This is the entry point module. Screen savers that link with scrnsave.lib are required to implement the ScreenSaverProc function. This function is called when the screen saver is started and terminated. Because the screen saver needs to enter a constantly running loop to function, this function starts a thread which handles the rest of the screen saver and returns immediately. Upon termination, it destroys the thread and ends the screen saver.

The thread creates an instance of the ScreenSaver class, which is a singleton (only one instance can exist at a time). It then calls the Heartbeat function, which is the screen saver's main loop, on that instance. This loop continually updates the virtual machine by calling Behave on it and then requesting a screen paint.


The settings dialog and registry reading and writing is handled by this module. ScreenSaverConfigureDialog, another required screen saver function, is augmented by a static Settings object. This module could probably use a little tidying up but it does the job well.


Nearly all of the DirectX code is contained in this module. The item of interest is the singleton Display class. The code is very minimal because screen savers don't have to deal with losing the device. The constructor initializes Direct3D and the device, the Paint function prepares the device for painting, and the Blt function does a nicely versatile job of painting 2D sprites.


This module is the core of the screen saver. Much of the code was taken directly from the Linux original. If you want to really understand it, you'll have to get into the code. I'll point out major landmarks though. Behave is called each time the main loop repeats. It in turn calls DoCycle which updates the state of the virtual machine. It also updates all the effects.

Effects are an addition I made to the screen saver that are not found in the original. In essence, the effects are a linked list of Effect structs. They are updated separately from the virtual machine itself and are painted on top of it.


<P>So that's an overview of the Windows Virtual Machine screen saver. You'll get the most benefit from it by rummaging through the code yourself. Feel free to ask any specific questions and I will go into greater detail.</P>
<P>Happy coding!</P>


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Squirrel Twirler
Web Developer
United States United States
No Biography provided

Comments and Discussions

QuestionUpdated the code. Pin
treytomes24-May-16 9:56
Membertreytomes24-May-16 9:56 
QuestionAny Updates? Pin
Bill96031-Jun-11 15:04
MemberBill96031-Jun-11 15:04 
GeneralThank you for sharing such a beautiful screensaver Pin
yoco31528-Apr-07 21:46
Memberyoco31528-Apr-07 21:46 
QuestionMicrosoft Visual C++ Runtime Library Pin
InsomniacXx27-Feb-07 16:10
MemberInsomniacXx27-Feb-07 16:10 
GeneralNice Screensaver! Pin
bneacetp22-Jun-04 21:17
Memberbneacetp22-Jun-04 21:17 
GeneralHere are changes for multi-monitor Pin
DaveMGrant13-Apr-04 5:46
MemberDaveMGrant13-Apr-04 5:46 
GeneralThanks alot ! Pin
Kochise15-Apr-04 22:29
MemberKochise15-Apr-04 22:29 
GeneralRe: Here are changes for multi-monitor Pin
Ryan Beesley23-Feb-05 13:03
MemberRyan Beesley23-Feb-05 13:03 
GeneralCPU 100% when ScreenSaver is running Pin
Hans Wieser13-Feb-04 9:02
MemberHans Wieser13-Feb-04 9:02 
GeneralRe: CPU 100% when ScreenSaver is running Pin
DaveMGrant13-Apr-04 5:49
MemberDaveMGrant13-Apr-04 5:49 
GeneralRe: CPU 100% when ScreenSaver is running Pin
Hans Wieser15-Apr-04 23:23
MemberHans Wieser15-Apr-04 23:23 
GeneralRe: CPU 100% when ScreenSaver is running Pin
DaveMGrant16-Apr-04 3:05
MemberDaveMGrant16-Apr-04 3:05 
GeneralDual Monitors Pin
smelton4-Feb-04 8:46
Membersmelton4-Feb-04 8:46 
GeneralCould not get it to compile. Pin
WREY22-Jan-04 4:39
MemberWREY22-Jan-04 4:39 
GeneralRe: Could not get it to compile. Pin
Squirrel Twirler22-Jan-04 10:17
MemberSquirrel Twirler22-Jan-04 10:17 
GeneralRe: Could not get it to compile. Pin
DaveMGrant13-Apr-04 5:48
MemberDaveMGrant13-Apr-04 5:48 
Yes, that fixes the problem.
QuestionMissing a point ? Pin
MarcosEdu22-Jan-04 0:07
MemberMarcosEdu22-Jan-04 0:07 
AnswerBecause this is a BeFreak interpreter emulator ! Pin
Kochise22-Jan-04 2:31
MemberKochise22-Jan-04 2:31 
GeneralTierra - Artificial Life in computer Pin
Kochise13-Feb-04 3:15
MemberKochise13-Feb-04 3:15 
GeneralLimitations :( Pin
Kochise20-Jan-04 6:15
MemberKochise20-Jan-04 6:15 
GeneralVC++ 7 Pin
Squirrel Twirler20-Jan-04 11:34
MemberSquirrel Twirler20-Jan-04 11:34 
GeneralVC++ 7 to VC++6 Pin
Kochise20-Jan-04 19:49
MemberKochise20-Jan-04 19:49 
GeneralMulti screen display Pin
nalpec20-Jan-04 5:32
Membernalpec20-Jan-04 5:32 
GeneralRe: Multi screen display Pin
paste0x7815-Nov-07 7:06
Memberpaste0x7815-Nov-07 7:06 
GeneralNice Job Pin
Domenic20-Jan-04 2:34
MemberDomenic20-Jan-04 2:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.