【问题标题】:Change Windows Lock Screen background image in C#在 C# 中更改 Windows 锁定屏幕背景图像
【发布时间】:2014-12-15 17:57:58
【问题描述】:

有没有办法在c#中使用pinvoke更改锁屏图像,如墙纸。

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern Int32 SystemParametersInfo(UInt32 action,
        UInt32 uParam, string vParam, UInt32 winIni);
private static readonly UInt32 SPI_SETDESKWALLPAPER = 20;
private static UInt32 SPIF_UPDATEINIFILE = 0x1;
private static uint MAX_PATH = 260;

// then I call
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, file, SPIF_UPDATEINIFILE);

我想对锁屏做同样的事情(就像 Bing 桌面应用正在做的那样)

【问题讨论】:

    标签: c# windows-8


    【解决方案1】:

    鉴于您的 Windows 8 标记,是的,您可以:

    LockScreen.SetImageFileAsync(),如Lock screen personalization sample in C# 所示(错误处理代码省略,请查看示例):

    StorageFile imageFile = await imagePicker.PickSingleFileAsync();
    
    // Application now has access to the picked file, setting image to lockscreen.  
    // This will fail if the file is an invalid format.
    await LockScreen.SetImageFileAsync(imageFile);
    

    【讨论】:

    • 其实我就是这么干的。但它第一次工作,现在什么都没有发生......
    • 好的,经过一番研究,如果我选择 x64 而不是任何 CPU,这段代码可以正常工作...你知道如何解决这个问题吗?
    • @Swell 不知道,抱歉。
    猜你喜欢
    • 2013-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-07
    相关资源
    最近更新 更多