'
十載的德江網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。網(wǎng)絡(luò)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整德江建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)從事“德江網(wǎng)站設(shè)計”,“德江網(wǎng)站推廣”以來,每個客戶項目都認(rèn)真落實執(zhí)行。
'!!!重要:首先要添加“引用”一個dll,選擇“System?Management”;
'
Imports?Microsoft.VisualBasic
Imports?System
Imports?System.Collections.Generic
Imports?System.ComponentModel
Imports?System.Data
Imports?System.Drawing
Imports?System.Text
Imports?System.Windows.Forms
Imports?System.Management
Imports?System.IO
Namespace?WindowsApplication1
Partial?Public?Class?Form1
Inherits?Form
Public?Sub?New()
InitializeComponent()
End?Sub
Private?Sub?button1_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取CPU編號
Dim?[MyClass]?As?New?ManagementClass("Win32_Processor")
Dim?MyCollection?As?ManagementObjectCollection?=?[MyClass].GetInstances()
Dim?MyInfo?As?String?=?"當(dāng)前系統(tǒng)CPU編號是:"
Dim?MyCPUID?As?String?=?""
For?Each?MyObject?As?ManagementObject?In?MyCollection
MyCPUID?=?MyObject.Properties("ProcessorId").Value.ToString()
Exit?For
Next?MyObject
MyInfo?=?MyCPUID
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button2_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機CPU的當(dāng)前電壓
Dim?MyInfo?As?String?=?"計算機CPU的當(dāng)前電壓是:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
Try
MyInfo?=?ControlChars.Lf??String.Format("CurrentVoltage?:?"??MyObject("CurrentVoltage").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Catch
End?Try
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button3_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機CPU的外部頻率
Dim?MyInfo?As?String?=?"計算機CPU的外部頻率是:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
Try
MyInfo?=?ControlChars.Lf??String.Format("ExtClock?:?"??MyObject("ExtClock").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Catch
End?Try
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button4_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機CPU的二級緩存
Dim?MyInfo?As?String?=?"計算機CPU的二級緩存尺寸是:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
MyInfo?=?ControlChars.Lf??String.Format("L2CacheSize:?"??MyObject("L2CacheSize").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button5_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機CPU的制造商名稱
Dim?MyInfo?As?String?=?"計算機CPU的制造商名稱是:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
MyInfo?=?ControlChars.Lf??String.Format("Manufacturer?:?"??MyObject("Manufacturer").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button6_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機CPU的產(chǎn)品名稱
Dim?MyInfo?As?String?=?"計算機CPU的產(chǎn)品名稱是:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
MyInfo?=?ControlChars.Lf??String.Format("Name?:?"??MyObject("Name").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button7_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機CPU的版本信息
Dim?MyInfo?As?String?=?"計算機CPU的版本信息如下:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
MyInfo?=?ControlChars.Lf??String.Format("Version:?"??MyObject("Version").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button8_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機CPU的當(dāng)前使用百分比?注意要把SQLserver或者其他耗CPU的軟件開著否則看不到效果就一直為0
Dim?MyInfo?As?String?=?"計算機CPU的當(dāng)前使用百分比是:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
MyInfo?=?ControlChars.Lf??String.Format("LoadPercentage?:?"??MyObject("LoadPercentage").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button9_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機CPU的最大時鐘頻率
Dim?MyInfo?As?String?=?"計算機CPU的最大時鐘頻率是:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
MyInfo?=?ControlChars.Lf??String.Format("MaxClockSpeed?:?"??MyObject("MaxClockSpeed").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button10_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機CPU的當(dāng)前時鐘頻率
Dim?MyInfo?As?String?=?"計算機CPU的當(dāng)前時鐘頻率是:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
MyInfo?=?ControlChars.Lf??String.Format("CurrentClockSpeed?:?"??MyObject("CurrentClockSpeed").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button11_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機的CPU地址寬度
Dim?MyInfo?As?String?=?"當(dāng)前計算機的CPU地址寬度是:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
MyInfo?=?ControlChars.Lf??String.Format("AddressWidth:?"??MyObject("AddressWidth").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
Private?Sub?button14_Click(ByVal?sender?As?Object,?ByVal?e?As?EventArgs)
'獲取計算機的CPU數(shù)據(jù)寬度
Dim?MyInfo?As?String?=?"當(dāng)前計算機的CPU數(shù)據(jù)寬度是:"
Dim?MySearcher?As?New?ManagementObjectSearcher("SELECT?*?FROM?Win32_Processor")
For?Each?MyObject?As?ManagementObject?In?MySearcher.Get()
MyInfo?=?ControlChars.Lf??String.Format("DataWidth?:?"??MyObject("DataWidth").ToString())
MyInfo?=?ControlChars.Lf??"========================================================="
Next?MyObject
MessageBox.Show(MyInfo,?"信息提示",?MessageBoxButtons.OK,?MessageBoxIcon.Information)
End?Sub
End?Class
用2個單選控件
按鈕下 如果 單選控件1狀態(tài)是選中的 就顯示窗體2 不是則顯示窗體3
或者 你可以顯示 圖像框控件2
vb.net的話
For
Each
sp
As
String
In
My.Computer.Ports.SerialPortNames
cbxport.Items.Add(sp)
Next
vb6.0的話要調(diào)用API查看串口相關(guān)信息存在的注冊表。
HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM
通過讀注冊表的方法獲得串口數(shù)量,當(dāng)然也可以獲得串口號了。
Option
Explicit
Private
Declare
Function
RegOpenKey
Lib
"advapi32.dll
"
Alias
"RegOpenKeyA
"
(ByVal
hKey
As
Long,
ByVal
lpSubKey
As
String,
phkResult
As
Long)
As
Long
Private
Declare
Function
RegQueryInfoKey
Lib
"advapi32.dll
"
Alias
"RegQueryInfoKeyA
"
(ByVal
hKey
As
Long,
ByVal
lpClass
As
String,
lpcbClass
As
Long,
ByVal
lpReserved
As
Long,
lpcSubKeys
As
Long,
lpcbMaxSubKeyLen
As
Long,
lpcbMaxClassLen
As
Long,
lpcValues
As
Long,
lpcbMaxValueNameLen
As
Long,
lpcbMaxValueLen
As
Long,
lpcbSecurityDescriptor
As
Long,
lpftLastWriteTime
As
Long)
As
Long
Private
Const
HKEY_LOCAL_MACHINE
=
H80000002
'
獲得當(dāng)前系統(tǒng)的
COM
口的數(shù)量
Function
GetCOMCount()
As
Integer
Dim
ret
As
Long,
cntCOM
As
Long
RegOpenKey
HKEY_LOCAL_MACHINE,
"HARDWARE\DEVICEMAP\SERIALCOMM
",
ret
RegQueryInfoKey
ret,
"
",
0,
0,
0,
0,
0,
cntCOM,
0,
0,
0,
GetCOMCount
=
cntCOM
End
Function
Private
Sub
Command1_Click()
MsgBox
"您的機器有
"
GetCOMCount
"
個串口。
",
vbOKOnly,
"串口數(shù)量
"
End
Sub
把圖片存入資源,或把路徑存放變量,在a,b的click事件中加載即可