重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net获取电脑配置 vbnet ini

vb获取网卡mac的完整代码

VB获取网卡MAC地址源代码

10余年的秀英网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整秀英建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“秀英网站设计”,“秀英网站推广”以来,每个客户项目都认真落实执行。

具体代码:(其中GetMACAddress() 函数为楼主所需函数)

Option Explicit

Public CheckCode As Long

Private Const NCBASTAT As Long = H33

Private Const NCBNAMSZ As Integer = 16

Private Const HEAP_ZERO_MEMORY As Long = H8

Private Const HEAP_GENERATE_EXCEPTIONS As Long = H4

Private Const NCBRESET As Long = H32

Private Type NCB

ncb_command As Byte

ncb_retcode As Byte

ncb_lsn As Byte

ncb_num As Byte

ncb_buffer As Long

ncb_length As Integer

ncb_callname As String * NCBNAMSZ

ncb_name As String * NCBNAMSZ

ncb_rto As Byte

ncb_sto As Byte

ncb_post As Long

ncb_lana_num As Byte

ncb_cmd_cplt As Byte

ncb_reserve(9) As Byte

ncb_event As Long

End Type

Private Type ADAPTER_STATUS

adapter_address(5) As Byte

rev_major As Byte

reserved0 As Byte

adapter_type As Byte

rev_minor As Byte

duration As Integer

frmr_recv As Integer

frmr_xmit As Integer

iframe_recv_err As Integer

xmit_aborts As Integer

xmit_success As Long

recv_success As Long

iframe_xmit_err As Integer

recv_buff_unavail As Integer

t1_timeouts As Integer

ti_timeouts As Integer

Reserved1 As Long

free_ncbs As Integer

max_cfg_ncbs As Integer

max_ncbs As Integer

xmit_buf_unavail As Integer

max_dgram_size As Integer

pending_sess As Integer

max_cfg_sess As Integer

max_sess As Integer

max_sess_pkt_size As Integer

name_count As Integer

End Type

Private Type NAME_BUFFER

name As String * NCBNAMSZ

name_num As Integer

name_flags As Integer

End Type

Private Type ASTAT

adapt As ADAPTER_STATUS

NameBuff(30) As NAME_BUFFER

End Type

Private Declare Function Netbios Lib "netapi32.dll" (pncb As NCB) As Byte

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, _

ByVal hpvSource As Long, _

ByVal cbCopy As Long)

Private Declare Function GetProcessHeap Lib "kernel32" () As Long

Private Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, _

ByVal dwFlags As Long, _

ByVal dwBytes As Long) As Long

Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, _

ByVal dwFlags As Long, _

lpMem As Any) As Long

Public Function GetMAC() As Integer

Dim bRet As Byte

Dim myNcb As NCB

Dim myASTAT As ASTAT

Dim pASTAT As Long

Dim intMAC As Integer

myNcb.ncb_command = NCBRESET

bRet = Netbios(myNcb)

With myNcb

.ncb_command = NCBASTAT

.ncb_lana_num = 0

.ncb_callname = "* "

.ncb_length = Len(myASTAT)

pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, .ncb_length)

End With

If pASTAT = 0 Then

Exit Function

End If

myNcb.ncb_buffer = pASTAT

bRet = Netbios(myNcb)

CopyMemory myASTAT, myNcb.ncb_buffer, Len(myASTAT)

intMAC = myASTAT.adapt.adapter_address(0)

intMAC = intMAC + myASTAT.adapt.adapter_address(1)

intMAC = intMAC + myASTAT.adapt.adapter_address(2)

intMAC = intMAC + myASTAT.adapt.adapter_address(3)

intMAC = intMAC + myASTAT.adapt.adapter_address(4)

intMAC = intMAC + myASTAT.adapt.adapter_address(5)

GetMAC = intMAC

Call HeapFree(GetProcessHeap(), 0, pASTAT)

End Function

Public Function GetMACAddress() As String

Dim bRet As Byte

Dim myNcb As NCB

Dim myASTAT As ASTAT

Dim pASTAT As Long

myNcb.ncb_command = NCBRESET

bRet = Netbios(myNcb)

With myNcb

.ncb_command = NCBASTAT

.ncb_lana_num = 0

.ncb_callname = "* "

.ncb_length = Len(myASTAT)

pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, .ncb_length)

End With

If pASTAT = 0 Then

Exit Function

End If

myNcb.ncb_buffer = pASTAT

bRet = Netbios(myNcb)

CopyMemory myASTAT, myNcb.ncb_buffer, Len(myASTAT)

GetMACAddress = HexEx(myASTAT.adapt.adapter_address(0)) "-" HexEx(myASTAT.adapt.adapter_address(1)) "-" HexEx(myASTAT.adapt.adapter_address(2)) "-" HexEx(myASTAT.adapt.adapter_address(3)) "-" HexEx(myASTAT.adapt.adapter_address(4)) "-" HexEx(myASTAT.adapt.adapter_address(5))

Call HeapFree(GetProcessHeap(), 0, pASTAT)

End Function

Private Function HexEx(ByVal B As Long) As String

Dim aa As String

aa = Hex$(B)

If Len(aa) 2 Then

aa = "0" aa

End If

HexEx = aa

End Function

编程问题 哪种编程语言比较好学?VB用的是什么语言?VC对电脑配置有何要求(多大的CPU 内存…)?

C# 容易学,就算不懂算法,不懂数据结构都可以学...

我们学校的04年的512内存的老古董都可以运行... 你说还有哪些电脑不行呢 = =

解释一下 .net 、VS、VC 和vb.net的开发环境...谢谢!

1. .net是微软的语言架构,是面向对象的托管语言;VS是Visual Studio的缩写,是微软的集成开发环境,通过它可以设计,开发和调试微软平台的程序,其中包括.net,也包括不是.net的程序;VC是Visual C的缩写,是微软版本的C语言,用来开发桌面应用,不能做网站;VB.NET是.net中的一种语言,和原来的VB完全不同,可以用来开发桌面和网站,VB.net的开发环境是VS.net(目前最高版本是vs2008)。

2. 做网站的话,需要安装VS(建议VS2008,因为更加强大),如果用SQL Server的话需要安装SQL Server(建议SQL2008,因为性能更好)。

3. VS2005和VS2008大小差不多,完全安装4G左右,最小安装1G左右

4. 如果使用数据库建议用2008因为2000马上就要停止技术支持了。

用vb获取计算机信息

模块

Public Function CheckComm()

On Error Resume Next

Set wshshell = CreateObject("wscript.shell")

wshshell.run ("%comspec% /c net start winmgmt"), 0

'用一个文本来记录硬件信息

'Set WshNetwork = CreateObject("WScript.Network")

'ComputerName = WshNetwork.ComputerName

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" strComputer "\root\cimv2")

'主板

Set board = objWMIService.ExecQuery("select * from win32_baseboard")

For Each item In board

board2 = "主板:" item.Product

Next

'CPU

Set cpu = objWMIService.ExecQuery("select * from win32_processor")

For Each item In cpu

cpu2 = "cpu:" item.Name

Next

'内存

Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory", , 48)

Dim memory1

For Each objItem In colItems

a = objItem.capacity / 1048576

temp = temp + Val(objItem.capacity)

If InStr(memory1, "1条" a "M") 0 Then

memory1 = Replace(memory1, "1条" a "M", "2条" a "M")

ElseIf InStr(memory1, "2条" a "M") 0 Then

memory1 = Replace(memory1, "2条" a "M", "3条" a "M")

ElseIf InStr(memory1, "3条" a "M") 0 Then

memory1 = Replace(memory1, "3条" a "M", "4条" a "M")

Else

memory1 = memory1 "1条" a "M"

End If

n = n + 1

Next

memory = temp / 1048576

If n = 1 Then

memory2 = "内存条:" memory1

Else

memory2 = "内存条:" memory1 " 总计" memory "M"

End If

'硬盘

Set disk = objWMIService.ExecQuery("select * from win32_diskdrive")

For Each item In disk

disk2 = "硬盘:" item.Model

Next

'显卡

Set video = objWMIService.ExecQuery("select * from win32_videocontroller", , 48)

For Each item In video

video2 = "显卡:" item.Description

Next

'网卡

Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter", , 48)

For Each objItem In colItems

If (Left(objItem.NetConnectionID, 4) = "本地连接") Then

lanname = "网卡:" objItem.Name

End If

Next

lan2 = lanname

Dim thecomputer(6)

thecomputer(0) = board2

thecomputer(1) = cpu2

thecomputer(2) = memory2

thecomputer(3) = disk2

thecomputer(4) = video2

thecomputer(5) = lan2

CheckComm = thecomputer

End Function

代码

Private Sub Form_Load()

List4.Clear

List4.AddItem "Computer Info" ' vbCrLf

List4.AddItem "***********************" ' vbCrLf

Dim I As Integer, c

c = CheckComm

For I = 0 To 5

List4.AddItem c(I)

Next

Dim s, System, item, d() As String

Set System = GetObject("winmgmts:").InstancesOf("Win32_ComputerSystem")

For Each item In System 'List1.AddItem item.cputype

's = "Computer Info" vbCrLf

's = s "***********************" vbCrLf

s = s "计算机名称: " item.Name vbCrLf

s = s "状态: " item.Status vbCrLf

s = s "类型: " item.SystemType vbCrLf

s = s "生产厂家: " item.Manufacturer vbCrLf

s = s "型号: " item.Model vbCrLf

s = s "内存: ~" item.totalPhysicalMemory \ 1024000 "mb" vbCrLf

s = s "域: " item.domain vbCrLf

's = s "工作组" item.Workgroup vbCrLf '获得工作组和域的选项不能同时用

s = s "当前用户: " item.UserName vbCrLf

s = s "启动状态" item.BootupState vbCrLf

s = s "该计算机属于" item.PrimaryOwnerName vbCrLf

s = s "系统类型" item.CreationClassName vbCrLf

s = s "计算机类类型" item.Description vbCrLf

On Error GoTo 1

For I = 0 To 1 '这里假设安装了两个系统

s = s Chr(5) "启动选项" I " :" item.SystemStartupOptions(I) _

vbCrLf

Next I

1:

Next

d = Split(s, vbCrLf)

For I = 0 To UBound(d)

List4.AddItem d(I)

Next

End Sub

要求一个list4


本文名称:vb.net获取电脑配置 vbnet ini
本文链接:http://cqcxhl.com/article/dosesih.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP