去网易聊天室,说一句“他妈的”,然后你会给网管踢出来,
这时!(“这时”两个字加重语气)你就看到你的地址了
63.133.xxx.xxx
这时!(“这时”两个字加重语气)你就看到你的地址了
63.133.xxx.xxx
解决方案 »
- 谁有installshile11.5的中文帮助
- 求怎么样测试erp软件?
- 300相送!!如何编程实现定时断开网络连接和定时连接上网络? 解决后另开贴送分
- 水晶报表8不支持带有临时表的存储过程么?
- 郁闷:为什么在基于对话框的应用程序中可以调用DLL中的对话框,但在基于框架的程序中调用却出错
- 计算重复产品的库存
- 自己写的Base64 Decoder!
- 高分想求一VB调用com+例子。
- listbox控件中显示数据库中的记录,我选中了其中的一些项,怎么让下次打开界面时 同样显示那些项目被选中????
- 求助一个老问题:xmlhttp中文处理
- 如何固定MDI窗体的大小?让他不能最大,最小化?
- 如何使WORD打开一个文件?另有100分酬谢!决不食言!
Option Explicit
Private Sub Form_Load()
ReDim TabArray(0 To 0) As Long
TabArray(0) = 61
'clear existing tabs and
'set the list tabstops
Call SendMessage(List2.hwnd, LB_SETTABSTOPS, 0&, ByVal 0&)
Call SendMessage(List2.hwnd, LB_SETTABSTOPS, 1&, TabArray(0))
List2.Refresh
'initialize winsock and load adapter data
SocketsInitialize
DisplayAdatersInfo
With Command1
.Enabled = List1.ListIndex > -1
.Caption = "Release IP"
End With
With Command2
.Enabled = List1.ListIndex > -1
.Caption = "Renew IP"
End With
End SubPrivate Sub Form_Unload(Cancel As Integer)
SocketsCleanup
End SubPrivate Sub Command1_Click()
Dim ip_index As Long
ip_index = CLng(List1.List(List1.ListIndex))
'assure an adapter index has been selected
If ip_index <> 0 Then
Screen.MousePointer = vbHourglass
'release the IP for the selected adapter
If IPRelease(ip_index) Then
DisplayAdatersInfo
End If
Screen.MousePointer = vbDefault
End If
End Sub
Private Sub Command2_Click()
Dim ip_index As Long
ip_index = CLng(List1.List(List1.ListIndex))
'assure an adapter index has been selected
If ip_index <> 0 Then
Screen.MousePointer = vbHourglass
'release the IP for the selected adapter
If IPRenew(ip_index) Then
DisplayAdatersInfo
End If
Screen.MousePointer = vbDefault
End If
End SubPrivate Sub List1_Click() Command1.Enabled = List1.ListIndex > -1
Command2.Enabled = List1.ListIndex > -1End SubPrivate Sub List1_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)List2.ListIndex = List1.ListIndex
End SubPrivate Sub List2_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
List1.ListIndex = List2.ListIndex
End SubSub DisplayAdatersInfo() 'populates two listboxes with adapter info 'working vars
Dim buff() As Byte
Dim cbRequired As Long
Dim Adapter As IP_ADAPTER_INFO
Dim ptr1 As Long
'clear the lists
List1.Clear
List2.Clear
Call GetAdaptersInfo(ByVal 0&, cbRequired) If cbRequired > 0 Then
ReDim buff(0 To cbRequired - 1) As Byte
If GetAdaptersInfo(buff(0), cbRequired) = ERROR_SUCCESS Then
ptr1 = VarPtr(buff(0))
'ptr1 is 0 when no more adapters
Do While (ptr1 <> 0)
CopyMemory Adapter, ByVal ptr1, LenB(Adapter)
With Adapter
List1.AddItem .dwIndex
List2.AddItem TrimNull(StrConv(.IpAddressList.IpAddress.IpAddr, vbUnicode)) _
& vbTab & _
TrimNull(StrConv(.sDescription, vbUnicode))
ptr1 = .dwNext
End With 'With Adapter
Loop 'Do While (ptr1 <> 0)
End If
End IfEnd SubPrivate Function TrimNull(item As String) Dim pos As Integer
'double check that there is a chr$(0) in the string
pos = InStr(item, Chr$(0))
If pos Then
TrimNull = Left$(item, pos - 1)
Else: TrimNull = item
End If
End Function
Public Declare Function gethostbyname lib "WSOCK32.DLL" (ByVal hotname$) as long
-----------------------
host_addr = gethostbyname(yourcomputername)
ipconfig
即可
Q160215 HOWTO: Obtain the Host IP Address Using Windows Sockets
http://support.microsoft.com/support/kb/articles/q160/2/15.asp
- 微软全球技术中心 VB技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查
(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
Q160215 HOWTO: Obtain the Host IP Address Using Windows Sockets
http://support.microsoft.com/support/kb/articles/q160/2/15.asp
- 微软全球技术中心 VB技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查
(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'在Form中
Private Const WS_VERSION_REQD = &H101
Private Const WS_VERSION_MAJOR = WS_VERSION_REQD \ &H100 And &HFF&
Private Const WS_VERSION_MINOR = WS_VERSION_REQD And &HFF&
Private Const MIN_SOCKETS_REQD = 1
Private Const SOCKET_ERROR = -1
Private Const WSADescription_Len = 256
Private Const WSASYS_Status_Len = 128 Private Type HOSTENT
hName As Long
hAliases As Long
hAddrType As Integer
hLength As Integer
hAddrList As Long
End Type Private Type WSADATA
wversion As Integer
wHighVersion As Integer
szDescription(0 To WSADescription_Len) As Byte
szSystemStatus(0 To WSASYS_Status_Len) As Byte
iMaxSockets As Integer
iMaxUdpDg As Integer
lpszVendorInfo As Long
End Type Private Declare Function WSAGetLastError Lib "WSOCK32.DLL" () As Long
Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal _
wVersionRequired As Integer, lpWSAData As WSADATA) As Long
Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
Private Declare Function gethostname Lib "WSOCK32.DLL" (ByVal hostname$, ByVal HostLen As Long) As Long
Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal hostname$) As Long
Private Declare Sub RtlMoveMemory Lib "KERNEL32" (hpvDest As Any, ByVal hpvSource&, ByVal cbCopy&) Function hibyte(ByVal wParam As Integer) hibyte = wParam \ &H100 And &HFF& End Function Function lobyte(ByVal wParam As Integer) lobyte = wParam And &HFF& End Function Sub SocketsInitialize()
Dim WSAD As WSADATA
Dim iReturn As Integer
Dim sLowByte As String, sHighByte As String, sMsg As String iReturn = WSAStartup(WS_VERSION_REQD, WSAD) If iReturn <> 0 Then
MsgBox "Winsock.dll is not responding."
End
End If If lobyte(WSAD.wversion) < WS_VERSION_MAJOR Or (lobyte(WSAD.wversion) = _
WS_VERSION_MAJOR And hibyte(WSAD.wversion) < WS_VERSION_MINOR) Then sHighByte = Trim$(Str$(hibyte(WSAD.wversion)))
sLowByte = Trim$(Str$(lobyte(WSAD.wversion)))
sMsg = "Windows Sockets version " & sLowByte & "." & sHighByte
sMsg = sMsg & " is not supported by winsock.dll "
MsgBox sMsg
End
End If 'iMaxSockets is not used in winsock 2. So the following check is only
'necessary for winsock 1. If winsock 2 is requested,
'the following check can be skipped. If WSAD.iMaxSockets < MIN_SOCKETS_REQD Then
sMsg = "This application requires a minimum of "
sMsg = sMsg & Trim$(Str$(MIN_SOCKETS_REQD)) & " supported sockets."
MsgBox sMsg
End
End If End Sub Sub SocketsCleanup()
Dim lReturn As Long lReturn = WSACleanup() If lReturn <> 0 Then
MsgBox "Socket error " & Trim$(Str$(lReturn)) & " occurred in Cleanup "
End
End If End Sub Sub Form_Load() SocketsInitialize End Sub Private Sub Form_Unload(Cancel As Integer) SocketsCleanup End Sub Private Sub Command1_click()
Dim hostname As String * 256
Dim hostent_addr As Long
Dim host As HOSTENT
Dim hostip_addr As Long
Dim temp_ip_address() As Byte
Dim i As Integer
Dim ip_address As String
If gethostname(hostname, 256) = SOCKET_ERROR Then
MsgBox "Windows Sockets error " & Str(WSAGetLastError())
Exit Sub
Else
hostname = Trim$(hostname)
End If
hostent_addr = gethostbyname(hostname) If hostent_addr = 0 Then
MsgBox "Winsock.dll is not responding."
Exit Sub
End If RtlMoveMemory host, hostent_addr, LenB(host)
RtlMoveMemory hostip_addr, host.hAddrList, 4 MsgBox hostname 'get all of the IP address if machine is multi-homed Do
ReDim temp_ip_address(1 To host.hLength)
RtlMoveMemory temp_ip_address(1), hostip_addr, host.hLength For i = 1 To host.hLength
ip_address = ip_address & temp_ip_address(i) & "."
Next
ip_address = Mid$(ip_address, 1, Len(ip_address) - 1) MsgBox ip_address ip_address = ""
host.hAddrList = host.hAddrList + LenB(host.hAddrList)
RtlMoveMemory hostip_addr, host.hAddrList, 4
Loop While (hostip_addr <> 0)
End Sub
的回答很好,帮了我大忙,谢谢,应该给分。