⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oeminfo.cs

📁 XP界面优化精灵, XP界面优化精灵
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;


using System.IO ;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace XP界面优化精灵
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Oeminfo : System.Windows.Forms.Form
	{

		OpenFileDialog ofd=new OpenFileDialog ();
		Bitmap temp =null;
		private System.Windows.Forms.TabControl tabControl1;
		private System.Windows.Forms.TabPage tabPage1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox tb_1;
		private System.Windows.Forms.TextBox tb_2;
		private System.Windows.Forms.TextBox tb_3;
		private System.Windows.Forms.Button bn_changeimage;
		private System.Windows.Forms.Button bn_deleteimage;
		private System.Windows.Forms.Button bn_saveOEM;
		private System.Windows.Forms.Button bn_look;
		private System.Windows.Forms.PictureBox pb_1;

		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Oeminfo()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Oeminfo));
			this.tabControl1 = new System.Windows.Forms.TabControl();
			this.tabPage1 = new System.Windows.Forms.TabPage();
			this.bn_look = new System.Windows.Forms.Button();
			this.bn_saveOEM = new System.Windows.Forms.Button();
			this.bn_deleteimage = new System.Windows.Forms.Button();
			this.bn_changeimage = new System.Windows.Forms.Button();
			this.pb_1 = new System.Windows.Forms.PictureBox();
			this.tb_3 = new System.Windows.Forms.TextBox();
			this.tb_2 = new System.Windows.Forms.TextBox();
			this.tb_1 = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.tabControl1.SuspendLayout();
			this.tabPage1.SuspendLayout();
			this.SuspendLayout();
			// 
			// tabControl1
			// 
			this.tabControl1.Controls.Add(this.tabPage1);
			this.tabControl1.Location = new System.Drawing.Point(4, 4);
			this.tabControl1.Name = "tabControl1";
			this.tabControl1.SelectedIndex = 0;
			this.tabControl1.Size = new System.Drawing.Size(372, 362);
			this.tabControl1.TabIndex = 0;
			// 
			// tabPage1
			// 
			this.tabPage1.BackColor = System.Drawing.Color.White;
			this.tabPage1.Controls.Add(this.bn_look);
			this.tabPage1.Controls.Add(this.bn_saveOEM);
			this.tabPage1.Controls.Add(this.bn_deleteimage);
			this.tabPage1.Controls.Add(this.bn_changeimage);
			this.tabPage1.Controls.Add(this.pb_1);
			this.tabPage1.Controls.Add(this.tb_3);
			this.tabPage1.Controls.Add(this.tb_2);
			this.tabPage1.Controls.Add(this.tb_1);
			this.tabPage1.Controls.Add(this.label4);
			this.tabPage1.Controls.Add(this.label3);
			this.tabPage1.Controls.Add(this.label2);
			this.tabPage1.Controls.Add(this.label1);
			this.tabPage1.Location = new System.Drawing.Point(4, 21);
			this.tabPage1.Name = "tabPage1";
			this.tabPage1.Size = new System.Drawing.Size(364, 337);
			this.tabPage1.TabIndex = 0;
			this.tabPage1.Text = "OEM信息";
			// 
			// bn_look
			// 
			this.bn_look.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.bn_look.Location = new System.Drawing.Point(178, 298);
			this.bn_look.Name = "bn_look";
			this.bn_look.TabIndex = 11;
			this.bn_look.Text = "看效果";
			this.bn_look.Click += new System.EventHandler(this.bn_look_Click);
			// 
			// bn_saveOEM
			// 
			this.bn_saveOEM.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.bn_saveOEM.Location = new System.Drawing.Point(90, 298);
			this.bn_saveOEM.Name = "bn_saveOEM";
			this.bn_saveOEM.TabIndex = 10;
			this.bn_saveOEM.Text = "保存";
			this.bn_saveOEM.Click += new System.EventHandler(this.bn_saveOEM_Click);
			// 
			// bn_deleteimage
			// 
			this.bn_deleteimage.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.bn_deleteimage.Location = new System.Drawing.Point(274, 226);
			this.bn_deleteimage.Name = "bn_deleteimage";
			this.bn_deleteimage.Size = new System.Drawing.Size(75, 30);
			this.bn_deleteimage.TabIndex = 9;
			this.bn_deleteimage.Text = "删除图片";
			this.bn_deleteimage.Click += new System.EventHandler(this.bn_deleteimage_Click);
			// 
			// bn_changeimage
			// 
			this.bn_changeimage.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.bn_changeimage.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.bn_changeimage.Location = new System.Drawing.Point(274, 184);
			this.bn_changeimage.Name = "bn_changeimage";
			this.bn_changeimage.Size = new System.Drawing.Size(75, 30);
			this.bn_changeimage.TabIndex = 8;
			this.bn_changeimage.Text = "更改图片";
			this.bn_changeimage.Click += new System.EventHandler(this.bn_changeimage_Click);
			// 
			// pb_1
			// 
			this.pb_1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.pb_1.Location = new System.Drawing.Point(76, 178);
			this.pb_1.Name = "pb_1";
			this.pb_1.Size = new System.Drawing.Size(180, 86);
			this.pb_1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.pb_1.TabIndex = 7;
			this.pb_1.TabStop = false;
			// 
			// tb_3
			// 
			this.tb_3.Location = new System.Drawing.Point(78, 86);
			this.tb_3.Multiline = true;
			this.tb_3.Name = "tb_3";
			this.tb_3.Size = new System.Drawing.Size(272, 76);
			this.tb_3.TabIndex = 6;
			this.tb_3.Text = "";
			// 
			// tb_2
			// 
			this.tb_2.Location = new System.Drawing.Point(78, 50);
			this.tb_2.Name = "tb_2";
			this.tb_2.Size = new System.Drawing.Size(272, 21);
			this.tb_2.TabIndex = 5;
			this.tb_2.Text = "";
			// 
			// tb_1
			// 
			this.tb_1.Location = new System.Drawing.Point(78, 14);
			this.tb_1.Name = "tb_1";
			this.tb_1.Size = new System.Drawing.Size(272, 21);
			this.tb_1.TabIndex = 4;
			this.tb_1.Text = "";
			// 
			// label4
			// 
			this.label4.AutoSize = true;
			this.label4.Location = new System.Drawing.Point(16, 210);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(60, 17);
			this.label4.TabIndex = 3;
			this.label4.Text = "图片设置:";
			// 
			// label3
			// 
			this.label3.AutoSize = true;
			this.label3.Location = new System.Drawing.Point(16, 118);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(60, 17);
			this.label3.TabIndex = 2;
			this.label3.Text = "支持信息:";
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.label2.Location = new System.Drawing.Point(16, 54);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(60, 17);
			this.label2.TabIndex = 1;
			this.label2.Text = "产品型号:";
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(16, 18);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(60, 17);
			this.label1.TabIndex = 0;
			this.label1.Text = "厂商名称:";
			// 
			// Oeminfo
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(380, 374);
			this.Controls.Add(this.tabControl1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.HelpButton = true;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "Oeminfo";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "OEM信息";
			this.TopMost = true;
			this.Load += new System.EventHandler(this.Form1_Load);
			this.tabControl1.ResumeLayout(false);
			this.tabPage1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.TopMost =action.isTopMost ;
			if(File.Exists (@"C:\WINDOWS\system32\Oeminfo.ini"))
			{
				StreamReader sr =new StreamReader (@"C:\WINDOWS\system32\Oeminfo.ini",System.Text.Encoding.GetEncoding ("gb2312"));
				while (sr.Peek()>0)
				{
					string info=sr.ReadLine();
					if(info.StartsWith("Manufacturer="))
					{
						this.tb_1.Text =info.Substring (info.IndexOf("=",0)+1);
					}
					else if(info.StartsWith("Model="))
					{
						this.tb_2.Text =info.Substring (info.IndexOf("=",0)+1);
					}
					else if(info.StartsWith("Line"))
					{
							this.tb_3.Text +=info.Substring (info.IndexOf("=",0)+1)+"\r\n";
					}
				}
				sr.Close ();
				this.tb_3.Text =this.tb_3 .Text .Remove(this.tb_3.Text.Length -2,2);
			}
			if(File.Exists (@"C:\WINDOWS\system32\OemLogo.bmp"))
			{
				this.pb_1.Image =Image.FromFile (@"C:\WINDOWS\system32\OemLogo.bmp");
			}
		}

		private void bn_changeimage_Click(object sender, System.EventArgs e)
		{
			ofd.Filter ="*.BMP | *.BMP";
			if(ofd.ShowDialog ()==DialogResult.OK )
			{
				this.pb_1.Image =Image.FromFile (ofd.FileName );
				this.temp =(Bitmap)Bitmap.FromFile (ofd.FileName );
			}
		}
		private void bn_deleteimage_Click(object sender, System.EventArgs e)
		{
			this.pb_1.Image=null;
		}

		private void bn_saveOEM_Click(object sender, System.EventArgs e)
		{
			StreamWriter sw=new StreamWriter (@"C:\WINDOWS\system32\Oeminfo.ini",false,System.Text.Encoding.GetEncoding ("gb2312"));
			sw.WriteLine ("[General]");
			sw.WriteLine ("Manufacturer="+this.tb_1.Text );
			sw.WriteLine ("Model="+this.tb_2.Text );
			sw.WriteLine ("[Support Information]");
			int i=1;
			string temp=tb_3.Text ;
			while(temp.IndexOf("\r\n")>0 || temp.Length>0)
			{
				string temp2="";
				if(temp.IndexOf("\r\n")>0)
				{
					temp2=temp.Substring(0,temp.IndexOf("\r\n"));
					temp=temp.Substring (temp.IndexOf("\r\n")+2);
				}
				else
				{
					sw.WriteLine("Line"+i+"="+temp);
					break;
				}
					sw.WriteLine("Line"+i+"="+temp2);
				i++;
			}
			sw.Close ();
			if(this.pb_1 .Image !=null)
			{
				if(this.temp != null)
				{
					Bitmap b=null;
					b=(Bitmap)Bitmap.FromFile(ofd.FileName );
					b.Save (@"C:\WINDOWS\system32\OemLogo.bmp");
				}
			}
			MessageBox.Show ("成功保存信息",action.Caption);
		}

		private void bn_look_Click(object sender, System.EventArgs e)
		{
			System.Diagnostics.Process.Start ("rundll32.exe","shell32.dll,Control_RunDLL SysDm.cpl,,0");
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -