Windows 10 中的壁纸更改

d65*_*65u 0 c# wallpaper windows-10

此代码适用于 Windows 7,但不适用于 Windows 10。而不是更改壁纸只是黑屏

[DllImport("User32", CharSet = CharSet.Auto)]
    public static extern int SystemParametersInfo(int uiAction, int uiParam,
        string pvParam, uint fWinIni);
    static void Main(string[] args)
    {
        SystemParametersInfo(0x0014, 0, "Image.jpg", 0x0001);
    }
Run Code Online (Sandbox Code Playgroud)

mag*_*981 5

而不是只通过Image.jpg,使用完整路径:

SystemParametersInfo(0x0014, 0, "C:\\Image.jpg", 0x0001);
Run Code Online (Sandbox Code Playgroud)