
正文
包含vb.netarp的词条
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb问题,急!!!
呵呵。
abc
写法错误
要ab
bc
才行的吧!
相关问答
Q1: 怎么在VB环境下使用winsock控件发送ARP和LLMNR协议报文呢?
需要自己组装报文,然后发送出去
首先要了解arp报文和LLMNR报文的结构才行
Q2: (200分)VB 获取本机IP和重新获取IP问题
DOS获取本机IP(括号内的为注释vb.netarp,输命令时别复制进去)。
方法1vb.netarp:arp -a (Interface:后面的就是你自己的IP地址)
方法2:ipconfig/all (IP Address后面的就是你自己的IP地址)
DOS重新获取IP
cmd /c ipconfig /release (释放IP,不执行这步下一步命令将无效)
cmd /c ipconfig /renew (重新获得IP)
上不了网或IP冲突时可以在记事本里贴入如下代码保存为如下文件名并执行vb.netarp:
重新获取IP.bat
@echo off
@echo 正在重新获取IPvb.netarp,请稍候....
cmd /c ipconfig /release nul
cmd /c ipconfig /renew nul
arp -a
@echo "Interface:后面的就是你自己的IP地址"
@echo "按任意建测试网络联通(不断跳说明网络正常)"
pause
ping -t
本程序在我的XP系统下测试通过。
在执行本程序前请不要绑定网卡IP,否则重新获取IP的二条命令无效。
-------------------------------------------------------
'VB获取本机IP
Private Sub Command1_Click()
Dim winIP As Object
Set winIP = CreateObject("MSWinsock.Winsock")
MsgBox "本机IP:" winIP.localip
End Sub
-------------------------------------------------------
'VB起用和禁用网络连接
Option Explicit
Private Const NetConnect = H31
Private Sub Command1_Click() '停用本地连接
Dim blnRelust As Boolean
'把 本地连接换成你要控制的本地连接的名字
blnRelust = ExcNetLinkMenu("本地连接", "停用(B)")
'xp
If blnRelust Then
Debug.Print "停用成功"
Else
blnRelust = ExcNetLinkMenu("本地连接", "禁用(B)")
End If
If blnRelust Then
Debug.Print "停用成功"
Else
Debug.Print "停用失败"
End If
End Sub
Private Sub command2_Click() '启用本地连接
'把 本地连接换成你要控制的本地连接的名字
Dim blnRelust As Boolean
blnRelust = ExcNetLinkMenu("本地连接", "启用(A)")
If blnRelust Then
Debug.Print "启用成功"
Else
Debug.Print "启用失败"
End If
End Sub
'首先引用Microsoft Shell Controls And Automation
'先找到“网络连接”这个虚拟文件夹,然后找到要控制的本地连接对应的folderitem,然后枚举verb,找到需要的verb后,调用verb的DoIt方法
Private Function ExcNetLinkMenu(ByVal AdapterName As String, ByVal MenuName As String) As Boolean
Dim objShell As New Shell32.Shell
Dim objFolder As Shell32.Folder
Dim objFolderItem As Shell32.FolderItem
Dim objShellFolderItem As ShellFolderItem
Dim objFolderItemVerb As Shell32.FolderItemVerb
Dim blnRelust As Boolean
On Error Resume Next
Set objFolder = objShell.NameSpace(NetConnect)
If ObjPtr(objFolder) = 0 Then
ExcNetLinkMenu = False
GoTo Exitfunction
End If
For Each objFolderItem In objFolder.Items '遍历网络连接文件夹集合
If objFolderItem.Name = AdapterName Then
Set objShellFolderItem = objFolderItem
blnRelust = True
Exit For
End If
Next
If blnRelust = False Then
ExcNetLinkMenu = False
GoTo Exitfunction
End If
For Each objFolderItemVerb In objShellFolderItem.Verbs '遍历本地连接的右键菜单
If objFolderItemVerb.Name = MenuName Then
objFolderItemVerb.DoIt
ExcNetLinkMenu = True
Exit For
End If
Next
If blnRelust = False Then ExcNetLinkMenu = False
Exitfunction:
Set objShell = Nothing
Set objFolder = Nothing
Set objFolderItem = Nothing
Set objShellFolderItem = Nothing
Set objFolderItemVerb = Nothing
End Function
Q3: 如何通过VB编程得到同一个局域网内的其它电脑的MAC地址??
Public Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long
Public Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIP As Long, ByVal SrcIP As Long, pMacAddr As Long, PhyAddrLen As Long) As Long
Public Declare Sub CopyMemory1 Lib "kernel32" Alias "RtlMoveMemory" (dst As Any, src As Any, ByVal bcount As Long)
Public Function GetRemoteMACAddress(ByVal sRemoteIP As String)
Dim dwRemoteIP As Long
Dim pMacAddr As Long
Dim bpMacAddr() As Byte
Dim PhyAddrLen As Long
Dim cnt As Long
Dim tmp As String
'convert the string IP into
'an unsigned long value containing
'a suitable binary representation
'of the Internet address given
dwRemoteIP = inet_addr(sRemoteIP)
If dwRemoteIP 0 Then
'set PhyAddrLen to 6
PhyAddrLen = 6
'retrieve the remote MAC address
On Error Resume Next
If SendARP(dwRemoteIP, 0, pMacAddr, PhyAddrLen) = 0 Then
'GetRemoteMACAddress = pMacAddr
'Exit Function
If pMacAddr 0 And PhyAddrLen 0 Then
'returned value is a long pointer
'to the mac address, so copy data
'to a byte array
ReDim bpMacAddr(0 To PhyAddrLen - 1)
CopyMemory1 bpMacAddr(0), pMacAddr, ByVal PhyAddrLen
'loop through array to build string
For cnt = 0 To PhyAddrLen - 1
If bpMacAddr(cnt) = 0 Then
tmp = tmp "00-"
Else
If Len(Hex$(bpMacAddr(cnt))) = 1 Then
tmp = tmp "0" Hex$(bpMacAddr(cnt)) "-"
Else
tmp = tmp Hex$(bpMacAddr(cnt)) "-"
End If
End If
Next
'remove the trailing dash
'added above and return True
If Len(tmp) 0 Then
'sRemoteMacAddress = Left$(tmp, Len(tmp) - 1)
GetRemoteMACAddress = Left$(tmp, Len(tmp) - 1)
End If
Exit Function
Else
GetRemoteMACAddress = False
End If
Else
GetRemoteMACAddress = False
End If 'SendARP
Else
GetRemoteMACAddress = False
End If 'dwRemoteIP
End Function
关于vb.netarp和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。







