Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1310769
  • 博文数量: 124
  • 博客积分: 5772
  • 博客等级: 大校
  • 技术积分: 1647
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-27 10:39
文章分类

全部博文(124)

文章存档

2020年(1)

2019年(1)

2018年(5)

2017年(2)

2016年(17)

2015年(3)

2014年(7)

2013年(11)

2012年(13)

2011年(30)

2010年(34)

分类: WINDOWS

2010-09-27 11:08:41

 控件类型           控件名
Listbox            LstAdapterName
 
窗体代码:
 
 

'===========================================
'Desc:获取本机网卡列表
'Author:yoyoba(stuyou@126.com)
'Date:2007-11-28
'Modify:2007-12-5
'===========================================

Option Explicit
Public WithEvents vpcap As vbPacket '声明一个使用vbpcap事件的vpcap对象变量
Dim AdapterString As String * 1000 'GetAdapterNames函数返回的网卡名,存放于该变量
Private Sub Form_Load()

    Set vpcap = New vbPacket '为对象变量vpcap赋值
    Dim NumAdapter As Long 'GetAdapterNames函数返回的网卡数,存放于该变量
    Dim AdapterList
    Dim i As Integer
   
    NumAdapter = vpcap.GetAdapterNames(AdapterString) '调用GetAdapterNames函数。获得本机网卡名字
   
    If NumAdapter = 0 Then
        MsgBox "Found NONE adapter on the Computer!,please check it!"
    Else
        AdapterList = Split(AdapterString, vbNullChar) '把获得网卡名置于LstAdapternName中
        For i = 0 To NumAdapter
            LstAdapterName.AddItem AdapterList(i)
        Next i
    End If
   
End Sub


阅读(1901) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-04-22 14:24:34

为什么按照楼主的代码,显示无网卡?而事实上有的,而且用WinPcap编程实现过了