Computer hardware information in VB.NET

zhaozj2021-02-16  198

Author: Meng will come from: [Meng] will be the best of the world

?

Get display resolution

DIM

X

AS

Short

=

System.windows.Forms.Screen.primaryScreen.bounds.width

DIM

Y

AS

Short

=

System.windows.Forms.Screen.primaryScreen.Bounds.Height

Msgbox

(

"

Your display resolution is:

"

&

X

&

"

X

"

&

Y)

Get the path to the special folder

'

"Desktop" desktop folder path

Msgbox

(Environment.GetFolderPath (Environment.SpecialFolder.DesktOpdirectory))

'

Favorites favorite path

Msgbox

(Environment.GetFolderPath (Environment.SpecialFolder.favorites))

'

"Application Data" path

Msgbox

(Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData))

'

Universal writing

'

DIM SPEC AS STRING = Environment.GetFolderPath (Environment.SpecialFolder.xxxxxxx)

'

XXXXXXX is the name of a special folder

Get operating system version information

Msgbox

(Environment.OSversion.toString)

Get the current login username

Msgbox

(Environment.Username) Get the path to the current application

Msgbox

(Environment.currentDirectory)

Open and close CD

-

ROM

'

New module first

Module McIapimodule

Module mciAPIModule Declare Function mciSendString () Function mciSendString Lib "winmm.dll" Alias ​​"mciSendStringA" _ (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _ ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As IntegerEnd Module

'

Open CD-ROM

DIM

Lret

AS

Long

Lret

=

McISendstring

"

Set cdaudio door open

"

,

0

&

,

0

,

0

)

'

Turn off CD-ROM

DIM

Lret

AS

Long

Lret

=

McISendstring

"

Set cdaudio door closed

"

,

0

&

,

0

,

0

)

'

For more details, please see

HTTP:

//msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mmcmdstr_8eyc.asp

Get full names of computer IP and computers

DIM

MYIP

AS

System.net.iphostentry

=

System.net.dns.gethostbyName (System.Net.dns.getHostName) MSGBOX

(

"

Your IP address:

"

&

(Myip.addressList.getValue

0

) .ToString))

Msgbox

(

"

Your computer full name:

"

&

(Myip.hostname.tostring)) Use Win32_Operatingsystem (WMI

Class)

Class) computer information obtained 'in Form1_Load added ListBox incident, and reference system.ManagmentDim opSearch As New ManagementObjectSearcher ( "SELECT * FROM Win32_OperatingSystem") Dim opInfo As ManagementObjectFor Each opInfo In opSearch.Get () ListBox1.Items.Add ( "Name : "& Opinfo (" name "). Tostring ()) Listbox1.items.Add (" Version: "& opinfo (" Version "). Tostring ()) ListBox1.Items.Add (" Manufacturer: "& opinfo (" Manufacturer "). Tostring ()) ListBox1.Items.Add (" CSName "). Tostring ()) ListBox1.Items.Add (" Windows Directory: "& opinfo (" WindowsDirectory). Tostring ())

List all the fonts installed by the computer and add to ListBox

'

New Form and add Listbox and Button

Private

Sub button1_click ()

Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim fntCollection As InstalledFontCollection = New InstalledFontCollection () Dim fntFamily () As FontFamilyfntFamily = fntCollection.FamiliesListBox1.Items.Clear () Dim i As Integer = 0for i = 0 TO FNTFAMILY.LENGTH - 1 ListBox1.Items.Add (FNTFamily (i) .name) Nextend Sub

Use Win32_Processor to list the information of the processor

Imports

System.Management

Public

Class Form1

Class Form1 Inherits System.Windows.Forms.Form # Region "Windows Form Designer Generated Code" Public Sub New () Sub New () MyBase.new () 'This call is required for the Windows Form Designer. InitializationComponent () 'Add any initialized End Sub' form to clean up the component list after the initializeComponent () call. Protected Overloads Overrides Sub Dispose () 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 Form Designer Required Private Components as System.comPonentModel.icontainer 'Note: The following procedure is necessary to use the Windows Form Designer to modify this process using the Windows Form Designer. 'Don't modify it using the code editor.

Friend WithEvents ListBox1 As System.Windows.Forms.ListBox Friend WithEvents Button1 As System.Windows.Forms.Button Private Sub InitializeComponent () Sub InitializeComponent () Me.ListBox1 = New System.Windows.Forms .Listbox me.button1 = new system.windows.Forms.Button Me.SuspendLayout () '' listbox1 'me.listbox1.location = new system.drawing.point (8, 8) me.listbox1.name = "listbox1" ME .Listbox1.size = new system.drawing.size (280, 186) me.listbox1.tabindex = 0 '' button1 'me.button1.location = new system.drawing.point (56, 208) me.button1.name = "Button1" me.button1.size = new system.drawing.size (168, 32) me.button1.tabindex = 1 me.button1.text = "Load computer processor information" 'Form1' me.autoscalebasesize = new system .Drawing.size (5, 13) me.clientsize = new system.drawing.size (296, 254) me.controls.addrange (new system.windows.forms.control () {me.button1, me.listbox1}) Me.Text = "Computer Processor Information "Me.ResumeLayout (False) End Sub # End Region Private Sub Button1_Click () Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles Button1.Click Dim ProcQuery As New SelectQuery (" Win32_Processor ") Dim ProcSearch As New ManagementObjectSearcher (ProcQuery) Dim procInfo As ManagementObject For Each procInfo In ProcSearch.Get () Call processorfamily (. procInfo ( "Family") ToString) ListBox1.Items.Add ( "Description:" & procInfo ( "Description") .Tostring ()) Listbox1.items.add ("CAPTION:" & procinfo ("

"). Tostring ()) Listbox1.items.add (" Architecture: "). Tostring ()) Call processORTYPE (Procinfo (" Processortype "). Tostring ()) Call CPustat (procinfo" ")"). TOSTRING) ListBox1.Items.add ("maxclockspeed:"). Tostring () & "mhz") listbox1.items.add ("l2cachespeed:"). Tostring () & "MHz") ListBox1.Items.Add ("ExtClock:" & Procinfo ("l2cachespeed"). Tostring () & "MHz") listbox1.items.add ("Processorid:" & procinfo ("Processorid" ) .Tostring ()) Listbox1.items.Add ("AddressWidth:"). Tostring () & "bits") listbox1.items.add ("DataWidth:" & procinfo ("DataWidth"). Tostring () & "bits") listbox1.items.add ("Version:" & procinfo ("version"). Tostring ()) Listbox1.Items.Add ("ExtClock:" & procinfo ("extclock"). Tostring ) & "Mhz") Next End Sub Function ProcessorFamily () Function ProcessorFamily (Byval Procssfam) DIM Processtype Select Case Proc ssfam Case 1 processtype = "Other" Case 2 processtype = "Unknown" Case 3 processtype = "8086" Case 4 processtype = "80286" Case 5 processtype = "80386" Case 6 processtype = "80486" Case 7 processtype = "8087" Case 8 Processtype = "80287" Case 9 Processtype = "

80387 "Case 10 processtype =" 80487 "Case 11 processtype =" Pentium brand "Case 12 processtype =" Pentium Pro "Case 13 processtype =" Pentium II "Case 14 processtype =" Pentium processor with MMX technology "Case 15 processtype =" Celeron "Case 16 processtype =" Pentium II Xeon "Case 17 processtype =" Pentium III "Case 18 processtype =" M1 Family "Case 19 processtype =" M2 Family "Case 24 processtype =" K5 Family "Case 25 processtype =" K6 Family " Case 26 processtype = "K6-2" Case 27 processtype = "K6-3" Case 28 processtype = "AMD Athlon Processor Family" Case 29 processtype = "AMD Duron Processor" Case 30 processtype = "AMD2900 Family" Case 31 processtype = " K6-2 "Case 32 Processtype =" Power PC Family "Case 33 Processtype =" PO WER PC 601 "Case 34 Processtype =" Power PC 603 "Case 35 Processtype =" Power PC 603 "Case 36 Processtype =" Power PC 604 "Case 37 ProcesSstype =" Power PC 620 "Case 38 Processtype =" Power PC X704 " Case 39 ProcesStype = "Power PC 750" Case 48 Processtype = "Alpha Family" Case 49 Processtype = "

Alpha 21064 "Case 50 processtype =" Alpha 21066 "Case 51 processtype =" Alpha 21164 "Case 52 processtype =" Alpha 21164PC "Case 53 processtype =" Alpha 21164a "Case 54 processtype =" Alpha 21264 "Case 55 processtype =" Alpha 21364 "Case 64 processtype =" MIPS Family "Case 65 processtype =" MIPS R4000 "Case 66 processtype =" MIPS R4200 "Case 67 processtype =" MIPS R4400 "Case 68 processtype =" MIPS R4600 "Case 69 processtype =" MIPS R10000 "Case 80 processtype = "SPARC Family" Case 81 processtype = "SuperSPARC" Case 82 processtype = "microSPARC II" Case 83 processtype = "microSPARC IIep" Case 84 processtype = "UltraSPARC" Case 85 processtype = "UltraSPARC II" Case 86 processtype = " Ultrasparc III "Case 87 Processtype =" Ultrasparc III "Case 88 processtype =" UltraSPARC IIIi "Case 96 processtype =" 68040 "Case 97 processtype =" 68xxx Family "Case 98 processtype =" 68000 "Case 99 processtype =" 68010 "Case 100 processtype =" 68020 "Case 101 processtype = "68030" Case 112 Processtype = "Hobbit Family"

Case 120 processtype = "Crusoe TM5000 Family" Case 121 processtype = "Crusoe TM3000 Family" Case 128 processtype = "Weitek" Case 130 processtype = "Itanium Processor" Case 144 processtype = "PA-RISC Family" Case 145 processtype = "PA- RISC 8500 "Case 146 Processtype =" PA-RISC 8000 "Case 147 Processtype =" PA-RISC 7300LC "Case 148 Processtype =" PA-RISC 7200 "CASE 149 Processtype =" PA-RISC 7100LC "Case 150 Processtype =" PA- RISC 7100 "Case 160 processtype =" V30 Family "Case 176 processtype =" Pentium III Xeon "Case 177 processtype =" Pentium III Processor with Intel SpeedStep Technology "Case 178 processtype =" Pentium 4 "Case 179 processtype =" Intel Xeon "Case 180 Processtype = "as400 family" case 181 processtype = "Intel Xeon Processor MP" Case 182 processtype = "AMD AthlonXP Family" Case 183 processtype = "AMD AthlonMP Family" Case 184 processtype = "Intel Itanium 2" Case 185 processtype = "AMD Opteron Family" Case 190 processtype = "K7" Case 200 processtype = "IBM390 Family" Case 201 processtype = "g4" case 202 processtype = "g5" case 250 processtype = "

i860 "Case 251 processtype =" i960 "Case 260 processtype =" SH-3 "Case 261 processtype =" SH-4 "Case 280 processtype =" ARM "Case 281 processtype =" StrongARM "Case 300 processtype =" 6x86 "Case 301 processtype = "MediaGX" Case 302 processtype = "MII" Case 320 processtype = "WinChip" Case 350 processtype = "DSP" Case 500 processtype = "Video Processor" End Select ListBox1.Items.Add ( "Family:" & processtype) End Function Function cpuStat () Function cpuStat (ByVal CpuStNUM) Dim stat Select Case CpuStNUM Case 0 stat = "Unknown" Case 1 stat = "CPU Enabled" Case 2 stat = "CPU Disabled by User via BIOS Setup" Case 3 stat = "CPU Disabled by bios (post error) "case 4 stat =" cpu is idle "case 5 stat =" reserved "case 6 stat =" reserved "case 7 stat = "Other" End Select ListBox1.Items.Add ( "CpuStatus:" & stat) End Function Function processortype () Function processortype (ByVal proctypenum) Dim proctype Select Case proctypenum Case 1 proctype = "Other" Case 2 proctype = "Unknown "Case 3 ProctyPe =" CAntral Processor "case 4 proctype =" math processor "case 5 procty =" DSP processor "

Case 6 proctype = "Video processor" end select listbox1.items.add ("Processor Type:" & procty) End Functionend Class gets a CD

-

ROM information

Imports

System.Management

Public

Class Form1

Class Form1 Inherits System.Windows.Forms.Form # Region "Windows Form Designer Generated Code" Public Sub New () Sub New () MyBase.new () 'This call is required for the Windows Form Designer. InitializationComponent () 'Add any initialized End Sub' form to clean up the component list after the initializeComponent () call. Protected Overloads Overrides Sub Dispose () 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 Form Designer Required 'Note: The following procedure is required by the Windows Form Designer' You can modify this process using the Windows Form Designer. 'Don't modify it using the code editor.

Private components As System.ComponentModel.IContainer Friend WithEvents ListBox1 As System.Windows.Forms.ListBox Private Sub InitializeComponent () Sub InitializeComponent () Me.ListBox1 = New System.Windows.Forms.ListBox Me .SuspendLayout () '' listbox1 'me.listbox1.location = new system.drawing.point (24, 16) me.listbox1.name = "listbox1" me.listbox1.size = new system.drawing.size (416, 173 ) Me.Listbox1.tabindex = 0 '' form1 'me.autoscalebasesize = new system.drawing.size (5, 13) me.clientsize = new system.drawing.size (456, 206) Me.Controls.addrange (New System) .Windows.forms.control () {me.listbox1} me.name = "form1" me.text = "form1" me.resumeLayout (false) end sub # end region private sub form1_load () SUB FORM1_LOAD (Byval Sender AS System.Object, ByVal e as system.eventargs _ handles mybase.load on Error ResMe next Dim SoundDeviceQuery As New SelectQuery ("Win32_CDROMDRIVE") DI m SoundDeviceSearch As New ManagementObjectSearcher (SoundDeviceQuery) Dim SoundDeviceInfo As ManagementObject For Each SoundDeviceInfo In SoundDeviceSearch.Get () Dim SizeInMBs As Long = (Val (SoundDeviceInfo ( "Size"). ToString ())) SizeInMBs = Int ((SizeInMBs / (1024 * 1024))) ListBox1.Items.Add ("CD-ROM Description:" & SoundDeviceInfo ("CAPTION"). Tostring ()) ListBox1.Items.Add ("CD-ROM Manufacturer:" & SoundDeviceInfo ("Manufacturer") .Tostring ()) Listbox1.items.add ("CD-ROM Drive:" & SoundDeviceInfo ("Drive"

) .Tostring ()) Listbox1.items.add ("CD-ROM Media Loaded:" & SoundDeviceInfo ("MediaLoaded"). Tostring ()) ListBox1.Items.Add ("CD-ROM Media Type:" & SoundDeviceInfo "). Tostring ()) Listbox1.items.add (" CD-ROM Volume Name: "& SoundDeviceInfo (" Volumename "). Tostring ()) ListBox1.Items.Add (" CD-ROM Size: "& SizeInMBS & "Mbytes") listbox1.items.add ("CD-ROM Status:" & SoundDeviceInfo ("status"). TOSTRING ()) listbox1.items.add ("CD-ROM Maxmediasize:" & SoundDeviceInfo ("Maxmediasize). Tostring ()) ListBox1.items.Add ("CD-ROM ID:" & SoundDeviceInfo ("ID"). TOSTRING ()) ListBox1.Items.Add ("CD-ROM Transferrate:" Int (SoundDeviceInfo ("TransforRrate" ) .Tostring ()) "KBS / Second") Next End Subend Class gets hard disk information

Imports

System.Management

Public

Class Form1

Class Form1 Inherits System.Windows.Forms.Form # Region "Windows Form Designer generated code" Public Sub New () Sub New () MyBase.New () InitializeComponent () End Sub Protected Overloads Overrides Sub Dispose () 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 Private components As System.ComponentModel.IContainer Friend WithEvents ListBox1 As System.Windows.Forms.ListBox Private Sub InitializeComponent () Sub InitializeComponent () Me.ListBox1 = New System.Windows.Forms.ListBox Me.SuspendLayout () '' ListBox1 'Me.ListBox1.Location = New System.Drawing. Point (8, 8) me.listbox1.name = "listbox1" me.listbox1.size = new system.drawing.size (272, 212) me.listbox1.tabindex = 0 '' form1 'me.autoscalebasesize = new system. Drawing.size (5, 13) me.clientsize = new sys Tem.drawing.size (292, 238) me.controls.windows.forms.control () {me.listbox1}) me.name = "form1" me.text = "form1" me.ResumeLayout False) End Sub # End Region Private Sub Form1_Load () Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load On Error Resume Next Dim HDDDeviceQuery As New SelectQuery ( "Win32_DiskDrive") Dim HDDDeviceSearch As new ManagementObjectSearcher (HDDDeviceQuery) Dim HDDDeviceInfo As ManagementObject For Each HDDDeviceInfo In HDDDeviceSearch.Get () ListBox1.Items.Add ( "HDD Description:" & HDDDeviceInfo ( "caption"

) .ToString ()) ListBox1.Items.Add ( "HDD BytesPerSector:" & HDDDeviceInfo ( "BytesPerSector") ToString ()) ListBox1.Items.Add ( "HDD CompressionMethod:".. & HDDDeviceInfo ( "CompressionMethod") ToString ( )) ListBox1.Items.Add ("HDD INDEX:" & HDDDeviceInfo ("index"). TOSTRING ()) Listbox1.Items.Add ("HDD INSTALDATE:" & HDDEviceInfo ("installdate"). Tostring ()) ListBox1. Items.add ("HDD Manufacturer:" & HDDDeviceInfo ("Manufacturer"). Tostring ()) ListBox1.Items.Add ("HDD Partitions:" & HDDEviceInfo ("partitions"). Tostring ()) ListBox1.Items.add ( "HDD SIZE:" & INT (Val (HDDDeviceInfo ("Size"). Tostring ()) / 2 ^ 30) & "gbytes") listbox1.items.add ("HDD Totalcylinders:" & HDDDeviceInfo ("Totalcylinders"). ToString ()) ListBox1.Items.Add ( "HDD TotalSectors:" & HDDDeviceInfo ( "TotalSectors") ToString ()) ListBox1.Items.Add ( "HDD TracksPerCylinder:" & HDDDeviceInfo ( "TracksPerCylinder").. ToString ()) Listbox1.items.add ("HDD Totalheads:" & HDDDeviceInfo ("Totalheads") .Tostring ()) Listbox1.items.add ("HDD Totaltracks:" & HDDDeviceInfo ("TOTALTRACKS"). TOSTRING ()) ListBox1.Items.Add ("HDD SectRack:" & HDDDeviceInfo ("SectRack"). Tostring () ListBox1.items.Add ("HDD SCSILogicalUnit:" & HDDDeviceInfo ("ScsilogicalUnit"). TOSTRING ()) Next End Subend Class gets the sound card information

Imports

System.Management

Public

Class Form1

Class Form1 Inherits System.Windows.Forms.Form # Region "Windows Form Designer generated code" Public Sub New () Sub New () MyBase.New () InitializeComponent () End Sub Protected Overloads Overrides Sub Dispose () 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 Private components As System.ComponentModel.IContainer Friend WithEvents ListBox1 As System.Windows.Forms.ListBox Private Sub InitializeComponent () Sub InitializeComponent () Me.ListBox1 = New System.Windows.Forms.ListBox Me.SuspendLayout () '' ListBox1 'Me.ListBox1.Location = New System.Drawing. Point (8, 8) me.listbox1.name = "listbox1" me.listbox1.size = new system.drawing.size (272, 212) me.listbox1.tabindex = 0 '' form1 'me.autoscalebasesize = new system. Drawing.size (5, 13) me.clientsize = new sys Tem.drawing.size (292, 238) me.controls.windows.forms.control () {me.listbox1}) me.name = "form1" me.text = "form1" me.ResumeLayout false) End Sub # End Region Private Sub Form1_Load () Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim SoundDeviceQuery As New SelectQuery ( "Win32_SoundDevice") Dim SoundDeviceSearch As New ManagementObjectSearcher (SoundDeviceQuery Dim SoundDeviceInfo As ManagementObject for Each SoundDeviceInfo in SoundDeviceSearch.get () ListBox1.items.Add ("Sound Device Description:" & SoundDeviceInfo ("

转载请注明原文地址:https://www.9cbs.com/read-8047.html

New Post(0)