首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >rundll32 UpdatePerUserSystemParameters不使用Windows 7

rundll32 UpdatePerUserSystemParameters不使用Windows 7
EN

Stack Overflow用户
提问于 2013-11-01 05:56:18
回答 1查看 8.2K关注 0票数 1

此vbs适用于XP,但Windows 7有问题,除非您再次登录,否则墙纸更改不会生效。有什么方法可以立即重绘桌面吗?谢谢

设w= WScript.CreateObject("Wscript.Shell") filePath = "D:\wp.bmp“ w.RegWrite“HKCU\控制面板\桌面\墙纸”,filePath w.Run“%windir%\System32 32\RundL32.EXEuser32.dll,UpdatePerUserSystemParameters",1,True

EN

回答 1

Stack Overflow用户

发布于 2013-11-01 18:21:51

谢谢各位,正如你们所说的,Powershell pInvoke方法确实是我在网上找到的唯一可行的解决方案,所以我在这里复制它,以防有人陷入同样的问题。

代码语言:javascript
复制
Add-Type @"
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace Wallpaper
{
   public class Setter {
      public const int SetDesktopWallpaper = 20;
      public const int UpdateIniFile = 0x01;
      public const int SendWinIniChange = 0x02;
      [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
      private static extern int SystemParametersInfo (int uAction, int uParam, string lpvParam, int fuWinIni);
      public static void SetWallpaper ( string path) {
         SystemParametersInfo( SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange );
         RegistryKey key = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
         key.Close();
      }
   }
}
"@

[Wallpaper.Setter]::SetWallpaper('D:\wp1.bmp')
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19721554

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档