-
Notifications
You must be signed in to change notification settings - Fork 1
/
frmSystemInfo.vb
executable file
·103 lines (99 loc) · 4.55 KB
/
frmSystemInfo.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Imports System.IO
Public Class frmSystemInfo
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim i As System.Management.ManagementObject
Dim searchInfo_Processor As New System.Management.ManagementObjectSearcher("Select * from Win32_Processor")
For Each i In searchInfo_Processor.Get()
txtProcessorName.Text = i("Name").ToString
txtProcessorID.Text = i("ProcessorID").ToString
txtProcessorDescription.Text = i("Description").ToString
txtProcessorManufacturer.Text = i("Manufacturer").ToString
txtProcessorL2CacheSize.Text = i("L2CacheSize").ToString
txtProcessorClockSpeed.Text = i("CurrentClockSpeed").ToString & " Mhz"
txtProcessorDataWidth.Text = i("DataWidth").ToString
txtProcessorExtClock.Text = i("ExtClock").ToString & " Mhz"
txtProcessorFamily.Text = i("Family").ToString
Next
Dim searchInfo_Board As New System.Management.ManagementObjectSearcher("Select * from Win32_BaseBoard")
For Each i In searchInfo_Board.Get()
txtBoardDescription.Text = i("Description").ToString
txtBoardManufacturer.Text = i("Manufacturer").ToString
txtBoardName.Text = i("Name").ToString
txtBoardSerialNumber.Text = i("SerialNumber").ToString
Next
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
End
End Try
End Sub
Private Sub SaveToFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToFileToolStripMenuItem.Click
Try
Dim fs As New FileStream("temp.txt", FileMode.Create, FileAccess.Write)
Dim w As New StreamWriter(fs)
w.Write("****** Processor Information ******")
w.WriteLine()
w.WriteLine()
w.WriteLine("Name")
w.WriteLine(txtProcessorName.Text)
w.WriteLine()
w.WriteLine("ID")
w.WriteLine(txtProcessorID.Text)
w.WriteLine()
w.WriteLine("Description")
w.WriteLine(txtProcessorDescription.Text)
w.WriteLine()
w.WriteLine("Manufacturer")
w.WriteLine(txtProcessorManufacturer.Text)
w.WriteLine()
w.WriteLine("L2 Cache Size")
w.WriteLine(txtProcessorL2CacheSize.Text)
w.WriteLine()
w.WriteLine("Clock Speed")
w.WriteLine(txtProcessorClockSpeed.Text)
w.WriteLine()
w.WriteLine("Data Width")
w.WriteLine(txtProcessorDataWidth.Text)
w.WriteLine()
w.WriteLine("Ext Clock")
w.WriteLine(txtProcessorExtClock.Text)
w.WriteLine()
w.WriteLine("Family")
w.WriteLine(txtProcessorFamily.Text)
w.WriteLine()
w.WriteLine("****** MotherBoard Information *****")
w.WriteLine()
w.WriteLine("Name")
w.WriteLine(txtBoardDescription.Text)
w.WriteLine()
w.WriteLine("Manufacturer")
w.WriteLine(txtBoardManufacturer.Text)
w.WriteLine()
w.WriteLine("Description")
w.WriteLine(txtBoardDescription.Text)
w.WriteLine()
w.WriteLine("Serial Number")
w.WriteLine(txtBoardSerialNumber.Text)
w.Flush()
w.Close()
With SaveFileDialog1
.AddExtension = True
.OverwritePrompt = True
.DefaultExt = "txt"
.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
.FileName = "SystemInfo"
.Filter = "Text files (*.txt)|*.txt|All files|*.*"
.FilterIndex = 1
.Title = "SystemInfo - Save file"
If .ShowDialog() = Windows.Forms.DialogResult.OK Then
My.Computer.FileSystem.MoveFile("temp.txt", .FileName, True)
End If
End With
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
End Try
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Close()
End Sub
End Class