| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2341 人关注过本帖, 1 人收藏
标题:[求助]vb扫描局域网电脑的IP和MAC地址的完整代码
只看楼主 加入收藏
mrzhousanlong
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-5-20
收藏(1)
 问题点数:0 回复次数:1 
[求助]vb扫描局域网电脑的IP和MAC地址的完整代码
跪求vb扫描局域网电脑的IP和MAC地址的完整代码.具体要求:图形界面.输入局域网的IP段,点扫描开始,把扫到的IP和对应的MAC地址列出来.再将MAC地址与姓名对应起来并显示.用什么数据库都可以,只要求MAC与姓名两元素,并且容易追加记录和维护.
请给出详细的代码和注释,并列出所用的控键,如果可以的话把整个做好的工程发到我邮箱里(mrzhousanlong@126.com)本人感激不尽!!!
搜索更多相关主题的帖子: 局域网 MAC 扫描 地址 
2007-05-20 21:10
细细的雨点
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-5-21
收藏
得分:0 

我做了一个扫描电脑IP和子网掩码!!你看看哦!! Option Explicit
Const REG_SZ As Long = 1
Const HKEY_LOCAL_MACHINE = &H80000002

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
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 RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" _
(ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, _
ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
Dim aaa As String


Private Sub Command1_Click()
Dim hKey As Long, hKey1 As Long, hKey2 As Long, ret As Long, ret1 As Long, lenData As Long, typeData As Long
Dim Name As String, name1 As String, name2 As String, s As String, S1 As String
Dim idx As Integer
idx = 0
Name = String(256, Chr(0))
RegCreateKey HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Services\Class\NetTrans", hKey
Text1.Text = hKey
Do
ret = RegEnumKey(hKey, idx, Name, Len(Name))
If ret = 0 Then
aaa = Left(Name, InStr(Name, Chr(0)) - 1)
aaa = "System\CurrentControlSet\Services\Class\NetTrans\" & aaa
ret = RegOpenKey(HKEY_LOCAL_MACHINE, aaa, hKey)
'获得IP地址
If ret = 0 Then
name1 = "IPAddress"
name2 = "IPMask"
ret = RegQueryValueEx(hKey, name1, 0, typeData, ByVal vbNullString, lenData)
s = String(lenData, Chr(0))
RegQueryValueEx hKey, name1, 0, typeData, ByVal s, lenData
If s <> "" Then s = Left(s, InStr(s, Chr(0)) - 1)
'获得子网掩码
ret1 = RegQueryValueEx(hKey, name2, 0, typeData, ByVal vbNullString, lenData)
S1 = String(lenData, Chr(0))
RegQueryValueEx hKey, name2, 0, typeData, ByVal S1, lenData
If S1 <> "" Then S1 = Left(S1, InStr(S1, Chr(0)) - 1)
If Val(s) > 0 Then
Text1.Text = s
Text2.Text = S1
Command2.Enabled = True
Exit Sub
End If
End If
idx = idx + 1
End If
Loop Until ret <> 0
End Sub
Private Sub Command2_Click()
Dim hKey As Long
If Text1.Text <> "" Then
RegCreateKey HKEY_LOCAL_MACHINE, aaa, hKey
' 修改IP地址
RegSetValueEx hKey, "IPAddress", 0, REG_SZ, ByVal Text1.Text, 13
' 修改子网掩码
RegSetValueEx hKey, "IPMask", 0, REG_SZ, ByVal Text2.Text, 13
RegCloseKey hKey
End If
End Sub

Private Sub Command3_Click()
End
End Sub

2007-05-21 09:26
快速回复:[求助]vb扫描局域网电脑的IP和MAC地址的完整代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018337 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved