zoukankan      html  css  js  c++  java
  • 编程实现改变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

  • 相关阅读:
    今日成长笔记2016-11-18
    牛人博客
    c 、c++、java区别
    Java开发中的23种设计模式详解
    JAVA编程规范
    设计及编码质量改进之降低耦合度
    加密
    敏捷开发之Scrum扫盲篇
    RPC
    李洪强iOS开发Swift篇—04_运算符
  • 原文地址:https://www.cnblogs.com/rr163/p/3994091.html
Copyright © 2011-2022 走看看