Programmatic implementation Change Win7 theme

Source: Internet
Author: User

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
  1. Using System;
  2. Using System.Collections.Generic;
  3. Using System.ComponentModel;
  4. Using System.Data;
  5. Using System.Drawing;
  6. Using System.Linq;
  7. Using System.Text;
  8. Using System.Windows.Forms;
  9. Using System.IO;
  10. Using System.Threading;
  11. Using System.Diagnostics;
  12. namespace Win7 Change theme
  13. {
  14. Public partial class Form1:form
  15. {
  16. Public Form1 ()
  17. {
  18. InitializeComponent ();
  19. string spath = Environment.getenvironmentvariable ("windir"); Get system Variable windir (Windows)
  20. DirectoryInfo DirectoryInfo = new DirectoryInfo (spath + @"\resources\themes\");
  21. foreach (FileInfo i in directoryinfo.getfiles ("*.theme"))
  22. {
  23. COMBOBOX1.ITEMS.ADD (I.fullname);
  24. }
  25. }
  26. private void button1_click (object sender, EventArgs e)
  27. {
  28. if (Combobox1.selectedindex = =-1)
  29. {
  30. return;
  31. }
  32. string sFile = ComboBox1.SelectedItem.ToString ();
  33. string scmd = string. Format (@ "
  34. rundll32.exe%systemroot%\system32\shell32.dll,control_rundll%systemroot%\system32\desk.cpl desk, @Themes/Action : Opentheme/file: "{0}" "", SFile); //cmd command
  35. Process cmd = new process ();
  36. Cmd.  Startinfo.filename = "cmd";
  37. Cmd.  Startinfo.redirectstandardinput = true;
  38. Cmd.  Startinfo.redirectstandardoutput = true;
  39. Cmd.  Startinfo.createnowindow = true;
  40. Cmd.  Startinfo.useshellexecute = false;
  41. Cmd. Start ();
  42. Cmd. Standardinput.writeline (Scmd);
  43. Cmd. Standardinput.flush ();
  44. Cmd. Standardinput.close ();
  45. Cmd. Close ();
  46. Cmd. Dispose ();
  47. }
  48. }
  49. }

Two execution procedures:

Three: Program source code Download:

http://download.csdn.net/detail/qq283868910/3866000

Programmatic implementation Change Win7 theme

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.