• 编程实现改变win7主题


    一  : 解析问题

    1. Windows 7 主题在:%windir%ResourcesThemes  :

     

    2: 我们通过shell 命令  (这个是msdn中提到的)

    rundll32.exe %SystemRoot%system32shell32.dll,Control_RunDLL %SystemRoot%system32desk.cpl desk,@Themes /Action:OpenTheme /file:" %SystemRoot%ResourcesThemesarchitecture.theme"

    3: 写代码  

    [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.   
    13. namespace win7改变主题  
    14. {  
    15.     public partial class Form1 : Form  
    16.     {  
    17.         public Form1()  
    18.         {  
    19.             InitializeComponent();  
    20.             string sPath = Environment.GetEnvironmentVariable("windir");//获取系统变量 windir(windows)  
    21.             DirectoryInfo directoryInfo = new DirectoryInfo(sPath + @"ResourcesThemes");  
    22.             foreach (FileInfo i in directoryInfo.GetFiles("*.theme"))  
    23.            {  
    24.                comboBox1.Items.Add(i.FullName);  
    25.            }  
    26.         }  
    27.   
    28.         private void button1_Click(object sender, EventArgs e)  
    29.         {  
    30.             if (comboBox1.SelectedIndex == -1)  
    31.             {  
    32.                 return;  
    33.             }  
    34.             string sFile = comboBox1.SelectedItem.ToString();  
    35.             string sCmd = string.Format(@"  
    36. rundll32.exe %SystemRoot%system32shell32.dll,Control_RunDLL %SystemRoot%system32desk.cpl desk,@Themes /Action:OpenTheme /file:""{0}""", sFile); //cmd命令  
    37.             Process cmd = new Process();  
    38.             cmd.StartInfo.FileName = "cmd";  
    39.             cmd.StartInfo.RedirectStandardInput = true;  
    40.             cmd.StartInfo.RedirectStandardOutput = true;  
    41.             cmd.StartInfo.CreateNoWindow = true;  
    42.             cmd.StartInfo.UseShellExecute = false;  
    43.             cmd.Start();  
    44.             cmd.StandardInput.WriteLine(sCmd);  
    45.             cmd.StandardInput.Flush();  
    46.             cmd.StandardInput.Close();  
    47.             cmd.Close();  
    48.             cmd.Dispose();  
    49.         }  
    50.     }  
    51. }  

    二 执行程序  如图:

     

    三 : 程序源代码 下载:

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

  • 相关阅读:
    84. Largest Rectangle in Histogram (Solution 2)
    84. Largest Rectangle in Histogram (Solution 1)
    73. Set Matrix Zeroes
    【JavaScript】Symbol 静态方法
    【JavaScript】Date
    【JavaScript】Math
    725. Split Linked List in Parts把链表分成长度不超过1的若干部分
    791. Custom Sort String字符串保持字母一样,位置可以变
    508. Most Frequent Subtree Sum 最频繁的子树和
    762. Prime Number of Set Bits in Binary Representation二进制中有质数个1的数量
  • 原文地址:https://www.cnblogs.com/rr163/p/3994091.html
Copyright © 2020-2023  润新知