c windows 动态壁纸

ffmpeg 里边就带有ffplay。安装一下ffmpeg就好,windows10 缩放会产生影响还未解决

#include <windows.h>
#include <stdio.h>

BOOL CALLBACK EnumWindowsProc(_In_ HWND hwnd, _In_ LPARAM Lparam)
{
    HWND hDefView = FindWindowExW(hwnd, 0, L"SHELLDLL_DefView", 0);
    if (hDefView != 0) {
        // 找它的下一个窗口,类名为WorkerW, 隐藏它
        HWND hWorkerW = FindWindowExW(0, hwnd, L"WorkerW", 0);
        ShowWindow(hWorkerW, SW_HIDE);

        return FALSE;
    }
    return TRUE;
}

int main(int argc, char* argv[])
{
    LPCWSTR lpParameter = L" C:/Users/Amazing/Desktop/1.mp4 -x 2560 -y 1440 -loop 0";
    STARTUPINFOW si{ 0 };
    PROCESS_INFORMATION pi{ 0 };

    if (CreateProcessW(L"D:/software/ffmpge/ffmpeg-N-100872-gd8b2fae3c7-win64-gpl/bin/ffplay.exe", (LPWSTR)lpParameter, 0, 0, 0, 0, 0, 0, &si, &pi))
    {
        Sleep(1000);                                                 // 等待视频播放器启动完成
        HWND hProgman = FindWindowW(L"Progman", 0);                  // 找到PM窗口
        SendMessageTimeout(hProgman, 0x52c, 0, 0, 0, 100, 0);                               // 给它发特殊消息
        HWND hFfplay = FindWindowW(L"SDL_app", 0);                   // 找到视频窗口
        SetParent(hFfplay, hProgman);                               // 将视频窗口设置为PM的子窗口
        EnumWindows(EnumWindowsProc, 0);                            // 找到第二个workerw窗口并隐藏它
    }
    return 0;
}
文章目录