One: Parsing problems
1. Windows 7 Theme in:%windir%\resources\themes:
2: We pass the shell command (this is mentioned in MSDN)
rundll32.exe%systemroot%\system32\shell32.dll,control_rundll%systemroot%\system32\desk.cpl desk, @Themes/Action : opentheme/file: " %systemroot%\resources\themes\architecture.theme"
3: Write code
[CSharp]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 Change theme
- {
- Public partial class Form1:form
- {
- Public Form1 ()
- {
- InitializeComponent ();
- string spath = Environment.getenvironmentvariable ("windir"); Get system Variable 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 command
- 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 ();
- }
- }
- }
Two execution procedures:
Three: Program source code Download:
http://download.csdn.net/detail/qq283868910/3866000
Programmatic implementation Change Win7 theme