如何使改变一台计算机的壁纸的批处理文件 [英] How to make a batch file that changes the wallpaper of a computer

查看:296
本文介绍了如何使改变一台计算机的壁纸的批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建以后将被转换为只要我打开它改变了我的电脑壁纸一个exe的批处理文件。对不起,我不知道如何做到这一点D:

I want to create a batch file that is later going to be converted to an exe that changes the wallpaper of my computer as soon as I open it. Sorry I have no idea how to do this D:

推荐答案

通常这个问题的答案是

reg add "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d  "c:\somewhere\something.bmp" /f

以设置在注册表中adecuated条目,随后

to set the adecuated entry in the registry, followed by

RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

要通知的变化的系统。

to inform the system of the changes.

BUT ,从Windows Vista这个办法是行不通的。或至少​​不为意。对注册表的更改将应用​​于新的登录。唯一可靠的方法来获得瞬间变壁纸是使用Windows API。

BUT, from windows Vista this approach does not work. Or at least not as intended. The changes to the registry will apply on new logon. The only robust way to get the wallpaper changed instantly is to use the windows api.

有关PowerShell的解决方案,可以在这里找到一个解决办法

For a powershell solution, you can find a solution here

如果你有机会获得一个C编译器,这code应该这样做(使用MinGW-GCC测试)

If you have access to a C compiler, this code should do the same (tested with mingw-gcc)

#include <windows.h>
int main(int argc, char **argv)
{
    if (argc < 2) return 1;
    if (! SystemParametersInfo(
            SPI_SETDESKWALLPAPER, 
            0, 
            argv[1],  
            SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE 
        )) return 2;
    return 0;
}

这篇关于如何使改变一台计算机的壁纸的批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆