一 : 解析问题
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:"mono, serif; background-color: #f8f8f8;"> %SystemRoot%\Resources\Themes\architecture.theme"
3: 写代码
[csharp]class="Apple-converted-space"> view plaincopy
- 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");
- 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);
- 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.net/detail/qq283868910/3866000