一 : 解析问题admin管理员组文章数量:1662302
1. Windows 7 主题在:%windir%\Resources\Themes :
2: 我们通过shell 命令 (这个是msdn中提到的)
rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:" %SystemRoot%\Resources\Themes\architecture.theme"
3: 写代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Diagnostics;
namespace win7改变主题
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string sPath = Environment.GetEnvironmentVariable("windir");//获取系统变量 windir(windows)
DirectoryInfo directoryInfo = new DirectoryInfo(sPath + @"\Resources\Themes\");
foreach (FileInfo i in directoryInfo.GetFiles("*.theme"))
{
comboBox1.Items.Add(i.FullName);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == -1)
{
return;
}
string sFile = comboBox1.SelectedItem.ToString();
string sCmd = string.Format(@"
rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:""{0}""", sFile); //cmd命令
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
cmd.StandardInput.WriteLine(sCmd);
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.Close();
cmd.Dispose();
}
}
}
二 执行程序 如图:
三 : 程序源代码 下载:
http://download.csdn/detail/qq283868910/3866000
本文标签: 主题
版权声明:本文标题:[C#] win7 改变主题 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1729960233a1217521.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论