知识大全 VB.NET中得到计算机硬件信息

Posted 信息

篇首语:惜时专心苦读是做学问的一个好方法。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 VB.NET中得到计算机硬件信息相关的知识,希望对你有一定的参考价值。

VB.NET中得到计算机硬件信息  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!

  本文汇集了中得到计算机硬件信息的一些功能

  得到显示器分辨率

  Dim X As Short = System <a _blank >Windows</a> Forms Screen PrimaryScreen Bounds Width    Dim Y As Short = System Windows Forms Screen PrimaryScreen Bounds Height    MsgBox( 您的显示器分辨率是 & X & X & Y)

  得到特殊文件夹的路径    Desktop 桌面文件夹路径    MsgBox(Environment GetFold<a _blank >ERP</a>ath(Environment SpecialFolder DesktopDirectory))    Favorites 收藏夹路径    MsgBox(Environment GetFolderPath(Environment SpecialFolder Favorites))    Application Data 路径    MsgBox(Environment GetFolderPath(Environment SpecialFolder ApplicationData))

   通用写法    Dim SPEC As String = Environment GetFolderPath(Environment SpecialFolder XXXXXXX)    XXXXXXX是特殊文件夹的名字

  得到操作系统版本信息    MsgBox(Environment OSVersion ToString)

  得到当前登录的用户名    MsgBox(Environment UserName)

  得到当前应用程序的路径    MsgBox(Environment CurrentDirectory)

  打开和关闭CD ROM    先新建模块Module mciAPIModule  Declare 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

   打开CD ROMDim lRet As LonglRet = mciSendString( set cdAudio door open & )

   关闭CD ROMDim lRet As LonglRet = mciSendString( set cdAudio door Closed & ) 更多请参见?url=/library/en us/multimed/mmcmdstr_ eyc asp

  得到计算机IP和计算机全名    Dim MYIP As System Net IPHostEntry = System Net Dns GetHostByName(System Net Dns GetHostName)    MsgBox( 您的IP地址 & (MYIP AddressList GetValue( ) ToString))    MsgBox( 您的计算机全名 & (MYIP HostName ToString))

  使用win _operatingSystem (wmi Class)得到计算机信息    添加ListBox在Form _Load事件里 并引用system Managment    Dim opSearch As New ManagementObjectSearcher( SELECT * FROM Win _OperatingSystem )    Dim opInfo As ManagementObject    For Each opInfo In opSearch Get()  ListBox Items Add( Name: & opInfo( name ) ToString())  ListBox Items Add( Version: & opInfo( version ) ToString())  ListBox Items Add( Manufacturer: & opInfo( manufacturer ) ToString())  ListBox Items Add( Computer name: & opInfo( csname ) ToString())  ListBox Items Add( Windows Directory: & opInfo( windowsdirectory ) ToString())Next

  列出计算机安装的全部字体 并添加到ListBox    新建Form并添加ListBox和ButtonPrivate Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) Handles Button ClickDim fntCollection As InstalledFontCollection = New InstalledFontCollection()Dim fntFamily() As FontFamilyfntFamily = fntCollection FamiliesListBox Items Clear()Dim i As Integer = For i = To fntFamily Length   ListBox Items Add(fntFamily(i) Name)NextEnd Sub

  使用Win _Processor列出处理器的信息Imports System ManagementPublic Class Form   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 (ponents Is Nothing) Then        ponents Dispose()      End If    End If    MyBase Dispose(disposing)  End Sub

   Windows 窗体设计器所必需的  Private ponents As System ComponentModel IContainer

   注意: 以下过程是 Windows 窗体设计器所必需的  可以使用 Windows 窗体设计器修改此过程   不要使用代码编辑器修改它   Friend WithEvents ListBox As System Windows Forms ListBox  Friend WithEvents Button As System Windows Forms Button  <System Diagnostics DebuggerStepThrough()> Private Sub InitializeComponent()    Me ListBox = New System Windows Forms ListBox    Me Button = New System Windows Forms Button    Me SuspendLayout()        ListBox         Me ListBox Location = New System Drawing Point( )    Me ListBox Name = ListBox     Me ListBox Size = New System Drawing Size( )    Me ListBox TabIndex =         Button         Me Button Location = New System Drawing Point( )    Me Button Name = Button     Me Button Size = New System Drawing Size( )    Me Button TabIndex =     Me Button Text = 装载计算机处理器信息         Form         Me AutoScaleBaseSize = New System Drawing Size( )    Me ClientSize = New System Drawing Size( )    Me Controls AddRange(New System Windows Forms Control() Me Button Me ListBox )    Me Text = 计算机处理器信息     Me ResumeLayout(False)

  End Sub

  #End Region

  Private Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) _   Handles Button Click

  Dim ProcQuery As New SelectQuery( Win _Processor )    Dim ProcSearch As New ManagementObjectSearcher(ProcQuery)    Dim ProcInfo As ManagementObject

  For Each ProcInfo In ProcSearch Get()      Call processorfamily(ProcInfo( Family ) ToString)      ListBox Items Add( Description: & ProcInfo( Description ) ToString())      ListBox Items Add( caption: & ProcInfo( caption ) ToString())      ListBox Items Add( Architecture: & ProcInfo( Architecture ) ToString())      Call processortype(ProcInfo( ProcessorType ) ToString())      Call CpuStat(ProcInfo( CpuStatus ) ToString)      ListBox Items Add( MaxClockSpeed: & ProcInfo( MaxClockSpeed ) ToString() & MHZ )      ListBox Items Add( L CacheSpeed: & ProcInfo( L CacheSpeed ) ToString() & MHZ )      ListBox Items Add( ExtClock: & ProcInfo( L CacheSpeed ) ToString() & MHZ )      ListBox Items Add( ProcessorId: & ProcInfo( ProcessorId ) ToString())      ListBox Items Add( AddressWidth: & ProcInfo( AddressWidth ) ToString() & Bits )      ListBox Items Add( DataWidth: & ProcInfo( DataWidth ) ToString() & Bits )      ListBox Items Add( Version: & ProcInfo( Version ) ToString())      ListBox Items Add( ExtClock: & ProcInfo( ExtClock ) ToString() & MHZ )    Next  End Sub  Function processorfamily(ByVal procssfam)    Dim processtype    Select Case procssfam      Case         processtype = Other       Case         processtype = Unknown       Case         processtype =       Case         processtype =       Case         processtype =       Case         processtype =       Case         processtype =       Case         processtype =       Case         processtype =       Case         processtype =       Case         processtype = Pentium brand       Case         processtype = Pentium Pro       Case         processtype = Pentium II       Case         processtype = Pentium processor with MMX technology       Case         processtype = Celeron       Case         processtype = Pentium II Xeon       Case         processtype = Pentium III       Case         processtype = M Family       Case         processtype = M Family       Case         processtype = K Family       Case         processtype = K Family       Case         processtype = K       Case         processtype = K       Case         processtype = AMD Athlon Processor Family       Case         processtype = AMD Duron Processor       Case         processtype = AMD Family       Case         processtype = K +       Case         processtype = Power PC Family       Case         processtype = Power PC       Case         processtype = Power PC       Case         processtype = Power PC +       Case         processtype = Power PC       Case         processtype = Power PC       Case         processtype = Power PC X       Case         processtype = Power PC       Case         processtype = Alpha Family       Case         processtype = Alpha       Case         processtype = Alpha       Case         processtype = Alpha       Case         processtype = Alpha PC       Case         processtype = Alpha a       Case         processtype = Alpha       Case         processtype = Alpha       Case         processtype = MIPS Family       Case         processtype = MIPS R       Case         processtype = MIPS R       Case         processtype = MIPS R       Case         processtype = MIPS R       Case         processtype = MIPS R       Case         processtype = SPARC Family       Case         processtype = SuperSPARC       Case         processtype = microSPARC II       Case         processtype = microSPARC IIep       Case         processtype = UltraSPARC       Case         processtype = UltraSPARC II       Case         processtype = UltraSPARC IIi       Case         processtype = UltraSPARC III       Case         processtype = UltraSPARC IIIi       Case         processtype =       Case         processtype = xxx Family       Case         processtype =       Case         processtype =       Case         processtype =       Case         processtype =       Case         processtype = Hobbit Family       Case         processtype = Crusoe TM Family       Case         processtype = Crusoe TM Family       Case         processtype = Weitek       Case         processtype = Itanium Processor       Case         processtype = PA RISC Family       Case         processtype = PA RISC       Case         processtype = PA RISC       Case         processtype = PA RISC LC       Case         processtype = PA RISC       Case         processtype = PA RISC LC       Case         processtype = PA RISC       Case         processtype = V Family       Case         processtype = Pentium III Xeon       Case         processtype = Pentium III Processor with Intel SpeedStep Technology       Case         processtype = Pentium       Case         processtype = Intel Xeon       Case         processtype = AS Family       Case         processtype = Intel Xeon processor MP       Case         processtype = AMD AthlonXP Family       Case         processtype = AMD AthlonMP Family       Case         processtype = Intel Itanium       Case         processtype = AMD Opteron Family       Case         processtype = K       Case         processtype = IBM Family       Case         processtype = G       Case         processtype = G       Case         processtype = i       Case         processtype = i       Case         processtype = SH       Case         processtype = SH       Case         processtype = arm       Case         processtype = Strongarm       Case         processtype = x       Case         processtype = MediaGX       Case         processtype = MII       Case         processtype = WinChip       Case         processtype = DSP       Case         processtype = Video Processor     End Select    ListBox Items Add( Family: & processtype)

  End Function  Function CpuStat(ByVal CpuStNUM)    Dim stat    Select Case CpuStNUM      Case         stat = Unknown       Case         stat = CPU Enabled       Case         stat = CPU Disabled by User via BIOS Setup       Case         stat = CPU Disabled By BIOS (POST Error)       Case         stat = CPU is Idle       Case         stat = Reserved       Case         stat = Reserved       Case         stat = Other     End Select    ListBox Items Add( CpuStatus: & stat)  End Function  Function processortype(ByVal proctypenum)    Dim proctype    Select Case proctypenum      Case         proctype = Other       Case         proctype = Unknown       Case         proctype = Central Processor       Case         proctype = Math Processor       Case         proctype = DSP Processor       Case         proctype = Video Processor     End Select    ListBox Items Add( Processor Type: & proctype)

  End FunctionEnd Class

  得到CD ROM信息Imports System ManagementPublic Class Form     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 (ponents Is Nothing) Then        ponents Dispose()      End If    End If    MyBase Dispose(disposing)  End Sub

   Windows 窗体设计器所必需的  注意: 以下过程是 Windows 窗体设计器所必需的  可以使用 Windows 窗体设计器修改此过程   不要使用代码编辑器修改它   Private ponents As System ComponentModel IContainer  Friend WithEvents ListBox As System Windows Forms ListBox  <System Diagnostics DebuggerStepThrough()> Private Sub InitializeComponent()    Me ListBox = New System Windows Forms ListBox    Me SuspendLayout()        ListBox         Me ListBox Location = New System Drawing Point( )    Me ListBox Name = ListBox     Me ListBox Size = New System Drawing Size( )    Me ListBox TabIndex =         Form         Me AutoScaleBaseSize = New System Drawing Size( )    Me ClientSize = New System Drawing Size( )    Me Controls AddRange(New System Windows Forms Control() Me ListBox )    Me Name = Form     Me Text = Form     Me ResumeLayout(False)

  End Sub

  #End Region

  Private Sub Form _Load(ByVal sender As System Object ByVal e As System EventArgs) _   Handles MyBase Load    On Error Resume Next    Dim SoundDeviceQuery As New SelectQuery( Win _CDROMDrive )    Dim 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 / ( * )))      ListBox Items Add( CD Rom Description: & SoundDeviceInfo( caption ) ToString())      ListBox Items Add( CD Rom Manufacturer: & SoundDeviceInfo( Manufacturer ) ToString())      ListBox Items Add( CD Rom Drive: & SoundDeviceInfo( drive ) ToString())      ListBox Items Add( CD Rom Media Loaded: & SoundDeviceInfo( MediaLoaded ) ToString())      ListBox Items Add( CD Rom Media Type: & SoundDeviceInfo( MediaType ) ToString())      ListBox Items Add( CD Rom Volume Name: & SoundDeviceInfo( VolumeName ) ToString())      ListBox Items Add( CD Rom Size: & SizeInMBs & MBytes )      ListBox Items Add( CD Rom Status: & SoundDeviceInfo( Status ) ToString())      ListBox Items Add( CD Rom MaxMediaSize: & SoundDeviceInfo( MaxMediaSize ) ToString())      ListBox Items Add( CD Rom Id: & SoundDeviceInfo( Id ) ToString())      ListBox Items Add( CD Rom TransferRate: +Int(SoundDeviceInfo( TransferRate ) ToString())+ KBs/秒 )    Next  End SubEnd Class

  得到硬盘信息Imports System ManagementPublic Class Form     Inherits System Windows Forms Form

  #Region Windows Form Designer generated code

  Public Sub New()    MyBase New()    InitializeComponent()  End Sub

  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)    If disposing Then      If Not (ponents Is Nothing) Then        ponents Dispose()      End If    End If    MyBase Dispose(disposing)  End Sub  Private ponents As System ComponentModel IContainer  Friend WithEvents ListBox As System Windows Forms ListBox  <System Diagnostics DebuggerStepThrough()> Private Sub InitializeComponent()    Me ListBox = New System Windows Forms ListBox    Me SuspendLayout()        ListBox         Me ListBox Location = New System Drawing Point( )    Me ListBox Name = ListBox     Me ListBox Size = New System Drawing Size( )    Me ListBox TabIndex =         Form         Me AutoScaleBaseSize = New System Drawing Size( )    Me ClientSize = New System Drawing Size( )    Me Controls AddRange(New System Windows Forms Control() Me ListBox )    Me Name = Form     Me Text = Form     Me ResumeLayout(False)

  End Sub

  #End Region

  Private Sub Form _Load(ByVal sender As System Object ByVal e As System EventArgs) Handles MyBase Load

  On Error Resume Next    Dim HDDDeviceQuery As New SelectQuery( Win _DiskDrive )    Dim HDDDeviceSearch As New ManagementObjectSearcher(HDDDeviceQuery)    Dim HDDDeviceInfo As ManagementObject    For Each HDDDeviceInfo In HDDDeviceSearch Get()      ListBox Items Add( HDD Description: & HDDDeviceInfo( caption ) ToString())      ListBox Items Add( HDD BytesPerSector: & HDDDeviceInfo( BytesPerSector ) ToString())      ListBox Items Add( HDD CompressionMethod: & HDDDeviceInfo( CompressionMethod ) ToString())      ListBox Items Add( HDD Index: & HDDDeviceInfo( Index ) ToString())      ListBox Items Add( HDD InstallDate: & HDDDeviceInfo( InstallDate ) ToString())      ListBox Items Add( HDD Manufacturer: & HDDDeviceInfo( Manufacturer ) ToString())      ListBox Items Add( HDD Partitions: & HDDDeviceInfo( Partitions ) ToString())      ListBox Items Add( HDD Size: & Int(Val(HDDDeviceInfo( Size ) ToString()) / ^ ) &   GBytes )      ListBox Items Add( HDD TotalCylinders: & HDDDeviceInfo( TotalCylinders ) ToString())      ListBox Items Add( HDD TotalSectors: & HDDDeviceInfo( TotalSectors ) ToString())      ListBox Items Add( HDD TracksPerCylinder: & HDDDeviceInfo( TracksPerCylinder ) ToString())      ListBox Items Add( HDD TotalHeads: & HDDDeviceInfo( TotalHeads ) ToString())      ListBox Items Add( HDD TotalTracks: & HDDDeviceInfo( TotalTracks ) ToString())      ListBox Items Add( HDD SectorsPerTrack: & HDDDeviceInfo( SectorsPerTrack ) ToString())      ListBox Items Add( HDD SCSILogicalUnit: & HDDDeviceInfo( SCSILogicalUnit ) ToString())    Next  End SubEnd Class

  得到声卡信息Imports System ManagementPublic Class Form     Inherits System Windows Forms Form

  #Region Windows Form Designer generated code

  Public Sub New()    MyBase New()    InitializeComponent()  End Sub

  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)    If disposing Then      If Not (ponents Is Nothing) Then        ponents Dispose()      End If    End If    MyBase Dispose(disposing)  End Sub  Private ponents As System ComponentModel IContainer  Friend WithEvents ListBox As System Windows Forms ListBox  <System Diagnostics DebuggerStepThrough()> Private Sub InitializeComponent()    Me ListBox = New System Windows Forms ListBox    Me SuspendLayout()        ListBox         Me ListBox Location = New System Drawing Point( )    Me ListBox Name = ListBox     Me ListBox Size = New System Drawing Size( )    Me ListBox TabIndex =         Form         Me AutoScaleBaseSize = New System Drawing Size( )    Me ClientSize = New System Drawing Size( )    Me Controls AddRange(New System Windows Forms Control() Me ListBox )    Me Name = Form     Me Text = Form     Me ResumeLayout(False)

  End Sub

  #End Region

  Private Sub Form _Load(ByVal sender As System Object ByVal e As System EventArgs) Handles MyBase Load    Dim SoundDeviceQuery As New SelectQuery( Win _SoundDevice )    Dim SoundDeviceSearch As New ManagementObjectSearcher(SoundDeviceQuery)    Dim SoundDeviceInfo As ManagementObject    For Each SoundDeviceInfo In SoundDeviceSearch Get()      ListBox Items Add( Sound Device Description: & SoundDeviceInfo( Caption ) ToString())      ListBox Items Add( Sound Device Status: & SoundDeviceInfo( status ) ToString())      ListBox Items Add( Sound Device Manufacturer: & SoundDeviceInfo( Manufacturer ) ToString())    Next  End Sub

cha138/Article/program/net/201311/11413

相关参考

知识大全 VB.NET读取INI文件设置信息函数sdGetIniInfo

VB.NET读取INI文件设置信息函数sdGetIniInfo  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来

知识大全 VB.Net调用存储过程并得到返回值

VB.Net调用存储过程并得到返回值  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  //存储过程

知识大全 c#(或vb.net)程序改进,可以提高性能

  使用值类型的ToString方法  在连接字符串时经常使用+号直接将数字添加到字符串中这种方法虽然简单也可以得到正确结果但是由于涉及到不同的数据类型数字需要通过装箱操作转化为引用类型才可以添加到字

试述计算机硬件系统各组成部件的主要功能?

  运算器:对数字信息进行运算和加工的部件;  控制器:计算机的控制中心;  存储器:用来存放计算机的程序及数据;  输入设备:获得信息的设备;  输出设备:向用户传递计算机处理结果的设备。

试述计算机硬件系统各组成部件的主要功能?

  运算器:对数字信息进行运算和加工的部件;  控制器:计算机的控制中心;  存储器:用来存放计算机的程序及数据;  输入设备:获得信息的设备;  输出设备:向用户传递计算机处理结果的设备。

知识大全 VB.NET中声音的播放

VB.NET中声音的播放  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 由VB升级为NET后有些人

知识大全 在VB.NET编程中使用数组

在VB.NET编程中使用数组  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  数组是程序中经常要使

知识大全 在VB.NET中进行抓屏

在VB.NET中进行抓屏  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!PublicClassFor

知识大全 vb.net中应用ArrayList 实例

vb.net中应用ArrayList实例  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  Arra

知识大全 VB.NET中对象的克隆[2]

VB.NET中对象的克隆[2]  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! Publi