C# Windows7锁屏设置图片路径 修改注册表
2018-03-20 15:05
323 查看
DirectoryInfo dir = new DirectoryInfo(url);
if (!dir.Exists)
{
msg = "锁屏资源不存在!";
return false;
}
FileInfo[] fis = dir.GetFiles("*.*", SearchOption.TopDirectoryOnly);
if (fis.Length <= 0)
{
msg = "背景图资源不存在!";
return false;
}
UIntPtr hKey;
int openOrCreate;
//WOW64_64Key起不被重定向作用
int iRst = RegCreateKeyEx(RegistryHive.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background",0,null,0,RegSAM.WOW64_64Key | RegSAM.Write, null, out hKey, out openOrCreate);
iRst = RegSetValueEx(hKey, "OEMBackground", 0, RegValueType.REG_DWORD, 1, 4);
iRst = RegCloseKey(hKey); //最后记得关闭已打开的键 IntPtr oldWOW64State = new IntPtr();
Wow64DisableWow64FsRedirection(ref oldWOW64State);//关闭文件重定向
// 把图片“backgroundDefault.jpg”放到目录“%windir%\system32\oobe\info\backgrounds\”里。
string sysBackgroundsDir = Environment.GetFolderPath(Environment.SpecialFolder.System)+ "\\oobe\\info\\backgrounds";
//string sysBackgroundsDir = "C:\\Windows\\System32\\oobe\\info\\backgrounds";
if (!Directory.Exists(sysBackgroundsDir))
{
DirectoryInfo di = Directory.CreateDirectory(sysBackgroundsDir);
}
File.Copy(fis[0].FullName, sysBackgroundsDir + "\\backgroundDefault.jpg", true);
Wow64RevertWow64FsRedirection(oldWOW64State);
if (!dir.Exists)
{
msg = "锁屏资源不存在!";
return false;
}
FileInfo[] fis = dir.GetFiles("*.*", SearchOption.TopDirectoryOnly);
if (fis.Length <= 0)
{
msg = "背景图资源不存在!";
return false;
}
UIntPtr hKey;
int openOrCreate;
//WOW64_64Key起不被重定向作用
int iRst = RegCreateKeyEx(RegistryHive.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background",0,null,0,RegSAM.WOW64_64Key | RegSAM.Write, null, out hKey, out openOrCreate);
iRst = RegSetValueEx(hKey, "OEMBackground", 0, RegValueType.REG_DWORD, 1, 4);
iRst = RegCloseKey(hKey); //最后记得关闭已打开的键 IntPtr oldWOW64State = new IntPtr();
Wow64DisableWow64FsRedirection(ref oldWOW64State);//关闭文件重定向
// 把图片“backgroundDefault.jpg”放到目录“%windir%\system32\oobe\info\backgrounds\”里。
string sysBackgroundsDir = Environment.GetFolderPath(Environment.SpecialFolder.System)+ "\\oobe\\info\\backgrounds";
//string sysBackgroundsDir = "C:\\Windows\\System32\\oobe\\info\\backgrounds";
if (!Directory.Exists(sysBackgroundsDir))
{
DirectoryInfo di = Directory.CreateDirectory(sysBackgroundsDir);
}
File.Copy(fis[0].FullName, sysBackgroundsDir + "\\backgroundDefault.jpg", true);
Wow64RevertWow64FsRedirection(oldWOW64State);
相关文章推荐
- c#设置软件开机自动运行,修改注册表
- C#设置注册表权限失败,修改应用程序以管理员身份执行
- C#设置自定义文件图标实现双击启动(修改注册表)
- c#设置软件开机自动运行,修改注册表
- c#设置软件开机自动运行,修改注册表
- C#设置软件开机自动运行的方法(修改注册表)
- Windows基础设置收藏:(二)通过修改注册表来设置一些软件中隐藏起来的路径设置
- wpf图片资源路径问题及C#代码设置图片路径
- c#设置软件开机自动运行,修改注册表
- c#设置软件开机自动运行,修改注册表
- C#设置自定义文件图标实现双击启动(修改注册表)
- 修改注册表设置桌面和收藏夹路径
- C# Asp.net 修改Ueditor编辑器上传图片保存路径
- js、c#修改ie设置,针对注册表的修改
- MVC 站点放在虚拟目录下 的 图片和JS文件路径设置
- 图片虚拟路径设置方法
- 修改JFileChooser对话框风格,设置打开对话框的默认文件名,获取改变路径之后的文件保存路径
- 通过注册表修改Win7下远程桌面端口3389的设置方法
- 修改图片大小和质量 C#