directx – How does the desktop live wallpaper program (winVista/7/8/8.1) work?

Question:

There is a DreamScenes program that allows you to set video wallpaper on your desktop (regular video in dream/wmv/mpg format). Also in VLC media player there is a function to display video in wallpaper mode (the sources of this program are available, but it was not possible to understand them: Sources ). What does the code that implements such a feature look like? So far, I was able to implement such a "miracle" in this way (example code, working):

#include <windows.h>
#include <iostream>
#include <fstream>

using namespace std;

void main()
{
    WIN32_FIND_DATA File;
    HANDLE F;
for(int i=0; i < 10; i++)  {
    F=FindFirstFile("C:\\leto\\*.jpg", &File);
    if (F!=INVALID_HANDLE_VALUE)
    {        do
                {
                ofstream bat("C:\\logo.bat", ios_base::out);
                bat << "REG ADD \"HKCU\\Control Panel\\Desktop\" /v Wallpaper /d \"C:\\leto\\" << File.cFileName <<"\" /f" << endl <<
                "rundll32.exe user32.dll,UpdatePerUserSystemParameters" << endl;
                bat.close();
                system("C:\\logo.vbs");
                Sleep(200);
                }
             while (FindNextFile(F,&File)!=0);
                FindClose(F);
    }
}
    system("pause");
}

Description: The folder contains pictures (animation frames). We find the first picture, write the code in the batch file that changes the desktop wallpaper to my picture, run the vbs script that allows you to execute the batch file in the background, then pause between the execution of the next command in the C ++ program (0.2 sec). Thus, the animation on the desktop is observed (but on the first pass it hangs, it is almost not performed, then it works, this is the problem). How to implement it normally, without freezing and a bunch of pictures, as in the programs mentioned at the beginning of the topic?

Answer:

Drawing can be done using DirectDraw, here is an example.

But , the solution is incompatible with Aero, you will have to turn it off.

Scroll to Top