|
Using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Using System.Data;
Using System.IO;
Using System.Diagnostics;
Download by Http://www.111cn.net
Namespace MyFile
{
<summary>
Summary description of the Form1.
</summary>
public class Form1:System.Windows.Forms.Form
{
Private System.Windows.Forms.Button button1;
Private System.Windows.Forms.TextBox TextBox1;
Private System.Windows.Forms.GroupBox GroupBox1;
Private System.Windows.Forms.OpenFileDialog OpenFileDialog1;
Private System.Windows.Forms.Button button2;
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.Label Label5;
Private System.Windows.Forms.Label label6;
Private System.Windows.Forms.Button Button3;
<summary>
The required designer variable.
</summary>
Private System.ComponentModel.Container components = null;
Public Form1 ()
{
//
Required for Windows Forms Designer support
//
InitializeComponent ();
//
TODO: Add any constructor code after the InitializeComponent call
//
}
<summary>
Clean up all resources that are in use.
</summary>
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (Components!= null)
{
Components. Dispose ();
}
}
Base. Dispose (disposing);
}
Code generated #region the Windows forms Designer
<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</summary>
private void InitializeComponent ()
{
This.button1 = new System.Windows.Forms.Button ();
This.textbox1 = new System.Windows.Forms.TextBox ();
This.groupbox1 = new System.Windows.Forms.GroupBox ();
This.openfiledialog1 = new System.Windows.Forms.OpenFileDialog ();
This.button2 = new System.Windows.Forms.Button ();
This.label1 = new System.Windows.Forms.Label ();
This.label2 = new System.Windows.Forms.Label ();
This.label3 = new System.Windows.Forms.Label ();
This.label4 = new System.Windows.Forms.Label ();
This.label5 = new System.Windows.Forms.Label ();
This.label6 = new System.Windows.Forms.Label ();
This.button3 = new System.Windows.Forms.Button ();
This.groupBox1.SuspendLayout ();
This. SuspendLayout ();
//
Button1
//
This.button1.Location = new System.Drawing.Point (8, 192);
This.button1.Name = "Button1";
This.button1.Size = new System.Drawing.Size (112, 23);
This.button1.TabIndex = 1;
This.button1.Text = "Browse program file";
This.button1.Click + = new System.EventHandler (This.button1_click);
//
TextBox1
//
This.textBox1.BackColor = System.Drawing.SystemColors.Control;
This.textBox1.Location = new System.Drawing.Point (104, 8);
This.textBox1.Name = "TextBox1";
This.textBox1.ReadOnly = true;
This.textBox1.Size = new System.Drawing.Size (256, 21);
This.textBox1.TabIndex = 2;
This.textBox1.Text = "";
//
GroupBox1
//
THIS.GROUPBOX1.CONTROLS.ADD (THIS.LABEL5);
THIS.GROUPBOX1.CONTROLS.ADD (THIS.LABEL4);
THIS.GROUPBOX1.CONTROLS.ADD (THIS.LABEL3);
THIS.GROUPBOX1.CONTROLS.ADD (THIS.LABEL2);
THIS.GROUPBOX1.CONTROLS.ADD (THIS.LABEL1);
This.groupBox1.Location = new System.Drawing.Point (8, 40);
This.groupBox1.Name = "GroupBox1";
This.groupBox1.Size = new System.Drawing.Size (352, 144);
This.groupBox1.TabIndex = 3;
This.groupBox1.TabStop = false;
This.groupBox1.Text = "program file information";
//
OpenFileDialog1
//
This.openFileDialog1.Filter = "program file (*.exe) |*.exe| All Files (*.*) |*.* ";
//
Button2
//
This.button2.Location = new System.Drawing.Point (120, 192);
This.button2.Name = "Button2";
This.button2.Size = new System.Drawing.Size (112, 23);
This.button2.TabIndex = 11;
This.button2.Text = "Get program file Information";
This.button2.Click + = new System.EventHandler (This.button2_click);
//
Label1
//
This.label1.Location = new System.Drawing.Point (16, 24);
This.label1.Name = "Label1";
This.label1.Size = new System.Drawing.Size (320, 16);
This.label1.TabIndex = 0;
This.label1.Text = "Company Name:";
//
Label2
//
This.label2.Location = new System.Drawing.Point (16, 48);
This.label2.Name = "Label2";
This.label2.Size = new System.Drawing.Size (320, 16);
This.label2.TabIndex = 1;
This.label2.Text = "Product Name:";
//
Label3
//
This.label3.Location = new System.Drawing.Point (16, 72);
This.label3.Name = "Label3";
This.label3.Size = new System.Drawing.Size (320, 16);
This.label3.TabIndex = 2;
This.label3.Text = "Language sign:";
//
Label4
//
This.label4.Location = new System.Drawing.Point (16, 96);
This.label4.Name = "Label4";
This.label4.Size = new System.Drawing.Size (320, 16);
This.label4.TabIndex = 3;
This.label4.Text = "version number:";
//
Label5
//
This.label5.Location = new System.Drawing.Point (16, 120);
This.label5.Name = "Label5";
This.label5.Size = new System.Drawing.Size (320, 16);
This.label5.TabIndex = 4;
This.label5.Text = "Copyright notice:";
//
Label6
//
This.label6.Location = new System.Drawing.Point (8, 16);
This.label6.Name = "Label6";
This.label6.Size = new System.Drawing.Size (96, 16);
This.label6.TabIndex = 12;
This.label6.Text = "program file name:";
//
Button3
//
This.button3.Location = new System.Drawing.Point (232, 192);
This.button3.Name = "Button3";
This.button3.Size = new System.Drawing.Size (128, 23);
This.button3.TabIndex = 13;
This.button3.Text = "Obtain this procedure file information";
This.button3.Click + = new System.EventHandler (This.button3_click);
//
Form1
//
This. AutoScaleBaseSize = new System.Drawing.Size (6, 14);
This. ClientSize = new System.Drawing.Size (368, 222);
This. Controls.Add (This.button3);
This. Controls.Add (THIS.LABEL6);
This. Controls.Add (This.groupbox1);
This. Controls.Add (This.textbox1);
This. Controls.Add (This.button1);
This. Controls.Add (This.button2);
This. MaximizeBox = false;
This. Name = "Form1";
This. StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
This. Text = "Demo Get program file Information";
This.groupBox1.ResumeLayout (FALSE);
This. ResumeLayout (FALSE);
}
#endregion
<summary>
The main entry point for the application.
</summary>
[STAThread]
static void Main ()
{
Application.Run (New Form1 ());
}
private void Button1_Click (object sender, System.EventArgs e)
{//Browse Program Files
if (This.openFileDialog1.ShowDialog () ==dialogresult.ok)
{
This.textbox1.text=this.openfiledialog1.filename;
}
}
private void button2_click (object sender, System.EventArgs e)
{//get program file information
string Myfilename=this.textbox1.text;
if (myfilename.length<1)
return;
String shortname=myfilename.substring (Myfilename.lastindexof ("\") +1);
this.groupbox1.text=shortname+ "program file Information";
fileversioninfo Myinfo=fileversioninfo.getversioninfo (myfilename);
this.label1.text= "Company name:" +myinfo.companyname;
this.label2.text= "Product name:" +myinfo.productname;
this.label3.text= "language mark:" +myinfo.language;
this.label4.text= Version number: "+myinfo.fileversion;"
this.label5.text= Copyright Notice: "+myinfo.legalcopyright;
}
private void Button3_Click (object sender, System.EventArgs e)
{//Get current program file information
this.groupbox1.text= "Display this procedure file information";
This.label1.text= "Company name:" +application.companyname;
this.label2.text= "Area information:" +application.currentculture;
this.label3.text= "Language sign:" +application.currentinputlanguage;
this.label4.text= "Product Name:" +application.productname;
this.label5.text= "Product version:" +application.productversion;
}
}
}
|