📄 form1.vb
字号:
Imports System
Imports System.IO
Imports System.Data
Imports System.Drawing
Imports System.Diagnostics
Imports System.ComponentModel
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.Button2 = New System.Windows.Forms.Button
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 88)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(80, 23)
Me.Label1.TabIndex = 0
Me.Label1.Text = "文件信息:"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 8)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(48, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "文件:"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(24, 48)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(248, 20)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(112, 8)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 24)
Me.Button1.TabIndex = 3
Me.Button1.Text = "打开文件"
'
'ListBox1
'
Me.ListBox1.Dock = System.Windows.Forms.DockStyle.Bottom
Me.ListBox1.Location = New System.Drawing.Point(0, 122)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(292, 212)
Me.ListBox1.TabIndex = 4
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(104, 80)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(88, 24)
Me.Button2.TabIndex = 5
Me.Button2.Text = "获取文件信息"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 334)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "文件信息"
Me.ResumeLayout(False)
End Sub
#End Region
Dim m_Path As String
Dim m_File As FileVersionInfo
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.CheckFileExists = True
OpenFileDialog1.CheckPathExists = True
OpenFileDialog1.AddExtension = True
OpenFileDialog1.Filter = "All Files(*.*)|*.*"
OpenFileDialog1.ShowDialog()
m_Path = OpenFileDialog1.FileName
If m_Path = "" Then
Exit Sub
Else
TextBox1.Text = m_Path
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim m_Fn As String
Dim m_Cmt As String
Dim m_Cm As String
Dim m_Fv As String
Dim m_Pv As String
Dim m_Pp As String
Dim m_Fd As String
Dim m_Pn As String
Dim m_Lan As String
Dim m_Lt As String
Dim m_On As String
Dim m_Sb As String
m_File = FileVersionInfo.GetVersionInfo(m_Path)
m_Fn = m_File.FileName
m_Fn = m_Fn.Substring(m_Fn.LastIndexOf("\") + 1)
m_Cmt = m_File.Comments
m_Cm = m_File.CompanyName
m_Fv = m_File.FileVersion
m_Pv = m_File.ProductVersion
m_Pn = m_File.ProductName
m_Pp = m_File.FilePrivatePart
m_Fd = m_File.FileDescription
m_Lan = m_File.Language
m_Lt = m_File.LegalTrademarks
m_On = m_File.OriginalFilename
m_Sb = m_File.SpecialBuild
ListBox1.Items.Add("*****************************************")
ListBox1.Items.Add("文件名:" & m_Fn)
ListBox1.Items.Add("文件注释:" & m_Cmt)
ListBox1.Items.Add("公司:" & m_Cm)
ListBox1.Items.Add("文件版本号:" & m_Fv)
ListBox1.Items.Add("产品版本号:" & m_Pv)
ListBox1.Items.Add("文件专用部件号:" & m_Pp)
ListBox1.Items.Add("产品名称:" & m_Pn)
ListBox1.Items.Add("文件说明:" & m_Fd)
ListBox1.Items.Add("版本信息区的默认语言字符串:" & m_Lan)
ListBox1.Items.Add("文件的商标和注册商标:" & m_Lt)
ListBox1.Items.Add("文件的特殊内部版本信息:" & m_Sb)
ListBox1.Items.Add("创建文件是所使用的名称:" & m_On)
ListBox1.Items.Add("******************************************")
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -