|
-
Jun 17th, 2000, 05:03 AM
#1
Thread Starter
Lively Member
How on your computer would you be able to find out your ip address?
Timbudtwo
I have no life, only one with computers.
VB 6.0 Enterprise Edition
[hr]
-
Jun 17th, 2000, 05:17 AM
#2
Junior Member
You have several kinds to know this.
Why do you need to know about this?
Are you on LAN?
Emidio do Nascimento
--------------------
Programmer, teacher and consultant.
[email protected]
Juiz de Fora/MG
BRAZIL
-
Jun 17th, 2000, 06:15 AM
#3
Or run the file - C:\WINDOWS\Winipcfg.exe.
-
Jun 17th, 2000, 06:45 AM
#4
PowerPoster
Hm,I tried both and both return 10.1.0.67 which is my IP behind the proxy I think... is there a way to get the 'real' IP?
-
Jun 17th, 2000, 06:53 AM
#5
Addicted Member
C:\WINDOWS\Winipcfg.exe will return your real ip even on a proxy server.
-
Jun 17th, 2000, 08:04 AM
#6
Frenzied Member
Some of your other answers may give you this, but might as well say it anyway.
Text1.text = Winsock1.LocalIP
-
Jun 17th, 2000, 08:24 AM
#7
Lively Member
Ok, are you dialing up or not... there is a big difference... if you aren't dialing up then the only ip you will ever have is your "fake"... but I presume that since you are using a proxy you aren't dialing up... there for you I think all you will ever get is the proxy address... which is one of the reasons some internet app's don't work behind a proxy.
-
Jun 17th, 2000, 08:38 AM
#8
Addicted Member
text1.text = Winsock1.LocalIP
won't give you your real ip on a proxy server, unless the winsock is connenected to something.
-
Jun 17th, 2000, 09:39 AM
#9
Addicted Member
text1.text = Winsock1.LocalIP
won't give you your real ip on a proxy server, unless the winsock is connenected to something.
??
It will give your IP but you need the winsock OCX added into you project You don't need to be connected to anything But It will return your "fake" ip (your poxy/lan ip)
-
Jun 17th, 2000, 10:42 AM
#10
Addicted Member
stick if you have the winsock loaded into your project and you are on a normal dial up it will return your ip address, but if you are on a proxy server and the winsock is not actually connected to anything its just idle, it does not give you your real ip address, it gives you some bogus ip address. for example I am on a proxy server and for me it always returns 4.0.0.3
which is not my ip address, but yet if the winsock control is actually connected to something it will give me my actual ip address.
-
Jun 17th, 2000, 10:58 AM
#11
Addicted Member
Yes i know that if you are on dial up it will give that,.
But When I Use It it give me my Lan Ip Address
Hmmm
Wonder Why
Any Way's Later
-
Jun 17th, 2000, 04:58 PM
#12
Lively Member
May work? Dunno, but worth a try...
I understand what your saying, but try the following code. It will return your IP (but it may not be the real one). Just try it and see, I have used this on my school network which is on a LAN, and it seemed to work OK.
Create a new Class file and name it "Net". Put the following code into it. BTW, this class also gives some other network / internet related functions. Just explore it.
Code:
'Net.cls
Option Explicit
Private Const INTERNET_CONNECTION_LAN As Long = &H2
Private Const INTERNET_CONNECTION_MODEM As Long = &H1
Private Const NCBASTAT = &H33
Private Const NCBNAMSZ = 16
Private Const HEAP_ZERO_MEMORY = &H8
Private Const HEAP_GENERATE_EXCEPTIONS = &H4
Private Const NCBRESET = &H32
Private Const MAX_WSADescription = 256
Private Const MAX_WSASYSStatus = 128
Private Const ERROR_SUCCESS As Long = 0
Private Const WS_VERSION_REQD As Long = &H101
Private Const WS_VERSION_MAJOR As Long = WS_VERSION_REQD \ &H100 And &HFF&
Private Const WS_VERSION_MINOR As Long = WS_VERSION_REQD And &HFF&
Private Const MIN_SOCKETS_REQD As Long = 1
Private Const SOCKET_ERROR As Long = -1
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 ' Reserved, must be 0
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 Type HostEnt
hName As Long
hAliases As Long
hAddrType As Integer
hLen As Integer
hAddrList As Long
End Type
Private Type WSADATA
wVersion As Integer
wHighVersion As Integer
szDescription(0 To MAX_WSADescription) As Byte
szSystemStatus(0 To MAX_WSASYSStatus) As Byte
wMaxSockets As Integer
wMaxUDPDG As Integer
dwVendorInfo As Long
End Type
Private Declare Function InternetGetConnectedState _
Lib "wininet.dll" (ByRef lpSFlags As Long, _
ByVal dwReserved As Long) As Long
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
Private Declare Function WSAGetLastError Lib "wsock32.dll" _
() As Long
Private Declare Function WSAStartup Lib "wsock32.dll" _
(ByVal wVersionRequired As Long, lpWSADATA As WSADATA) As Long
Private Declare Function WSACleanup Lib "wsock32.dll" () As Long
Private Declare Function gethostname Lib "wsock32.dll" _
(ByVal szHost As String, ByVal dwHostLen As Long) As Long
Private Declare Function gethostbyname Lib "wsock32.dll" _
(ByVal szHost As String) As Long
'~Function for retrieving the MAC or ethernet address
' from the networked machine. On error, the returned string
' will equal 8 zeros.
Public Function GetEthernet() As String
Dim udtNCB As NCB
Dim bytResponse As Byte
Dim udtASTAT As ASTAT
Dim udtTempASTAT As ASTAT
Dim lngASTAT As Long
Dim strOut As String
Dim x As Integer
udtNCB.ncb_command = NCBRESET
bytResponse = Netbios(udtNCB)
udtNCB.ncb_command = NCBASTAT
udtNCB.ncb_lana_num = 0
udtNCB.ncb_callname = "* "
udtNCB.ncb_length = Len(udtASTAT)
lngASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, udtNCB.ncb_length)
strOut = ""
If lngASTAT Then
udtNCB.ncb_buffer = lngASTAT
bytResponse = Netbios(udtNCB)
CopyMemory udtASTAT, udtNCB.ncb_buffer, Len(udtASTAT)
With udtASTAT.adapt
For x = 0 To 5
strOut = strOut & Right$("00" & Hex$(.adapter_address(x)), 2)
Next x
End With
HeapFree GetProcessHeap(), 0, lngASTAT
End If
GetEthernet = strOut
End Function
Public Function GetIPAddress() As String
Dim sHostName As String * 256
Dim lpHost As Long
Dim Host As HostEnt
Dim dwIPAddr As Long
Dim tmpIPAddr() As Byte
Dim i As Integer
Dim sIPAddr As String
If Not SocketsInitialize() Then
GetIPAddress = ""
Exit Function
End If
If gethostname(sHostName, 256) = SOCKET_ERROR Then
GetIPAddress = ""
'MsgBox "Windows Sockets error " & Str$(WSAGetLastError()) & _
' " has occurred. Unable to successfully get Host Name."
SocketsCleanup
Exit Function
End If
sHostName = Trim$(sHostName)
lpHost = gethostbyname(sHostName)
If lpHost = 0 Then
GetIPAddress = ""
'MsgBox "Windows Sockets are not responding. " & _
' "Unable to successfully get Host Name."
SocketsCleanup
Exit Function
End If
CopyMemory Host, lpHost, Len(Host)
CopyMemory dwIPAddr, Host.hAddrList, 4
ReDim tmpIPAddr(1 To Host.hLen)
CopyMemory tmpIPAddr(1), dwIPAddr, Host.hLen
For i = 1 To Host.hLen
sIPAddr = sIPAddr & tmpIPAddr(i) & "."
Next
GetIPAddress = Mid$(sIPAddr, 1, Len(sIPAddr) - 1)
SocketsCleanup
End Function
Public Function GetIPHostName() As String
Dim sHostName As String * 256
If Not SocketsInitialize() Then
GetIPHostName = ""
Exit Function
End If
If gethostname(sHostName, 256) = SOCKET_ERROR Then
GetIPHostName = "Error in retrieving IP host name!"
Resume Next
'MsgBox "Windows Sockets error " & Str$(WSAGetLastError()) & _
'" has occurred. Unable to successfully get Host Name."
SocketsCleanup
Exit Function
End If
GetIPHostName = Left$(sHostName, InStr(sHostName, Chr(0)) - 1)
SocketsCleanup
End Function
Private Function HiByte(ByVal wParam As Integer)
HiByte = wParam \ &H100 And &HFF&
End Function
Private Function LoByte(ByVal wParam As Integer)
LoByte = wParam And &HFF&
End Function
Private Sub SocketsCleanup()
If WSACleanup() <> ERROR_SUCCESS Then
Resume Next
End If
End Sub
Private Function SocketsInitialize() As Boolean
Dim WSAD As WSADATA
Dim sLoByte As String
Dim sHiByte As String
If WSAStartup(WS_VERSION_REQD, WSAD) <> ERROR_SUCCESS Then
'"The 32-bit Windows Socket is not responding."
SocketsInitialize = False
Exit Function
End If
If WSAD.wMaxSockets < MIN_SOCKETS_REQD Then
'MsgBox "This application requires a minimum of " & _
CStr(MIN_SOCKETS_REQD) & " supported sockets."
SocketsInitialize = False
Exit Function
End If
If LoByte(WSAD.wVersion) < WS_VERSION_MAJOR Or _
(LoByte(WSAD.wVersion) = WS_VERSION_MAJOR And _
HiByte(WSAD.wVersion) < WS_VERSION_MINOR) Then
sHiByte = CStr(HiByte(WSAD.wVersion))
sLoByte = CStr(LoByte(WSAD.wVersion))
'MsgBox "Sockets version " & sLoByte & "." & sHiByte & _
' " is not supported by 32-bit Windows Sockets."
SocketsInitialize = False
Exit Function
End If
SocketsInitialize = True
End Function
Property Get GetOnline() As Boolean
GetOnline = InternetGetConnectedState(0&, 0&)
End Property
Property Get GetStateOnline() As String
If GetOnline Then
GetStateOnline = "Active."
Else
GetStateOnline = "Inactive."
End If
End Property
Public Function ViaLAN() As Boolean
Dim SFlags As Long
'return the flags associated with the connection
Call InternetGetConnectedState(SFlags, 0&)
'True if the Sflags has a LAN connection
ViaLAN = SFlags And INTERNET_CONNECTION_LAN
End Function
Public Function ViaModem() As Boolean
Dim SFlags As Long
'return the flags associated with the connection
Call InternetGetConnectedState(SFlags, 0&)
'True if the Sflags has a modem connection
ViaModem = SFlags And INTERNET_CONNECTION_MODEM
End Function
Now, in a form, or a module.
Code:
Dim netCls As New Net
'To get the local IP, call this. It returns a string containing the IP of your machine.
Msgbox netCls.GetIPAddress
Hope this helps in some way...
Laterz
REM
-
Jun 17th, 2000, 07:29 PM
#13
-
Feb 20th, 2011, 08:57 PM
#14
Frenzied Member
Re: May work? Dunno, but worth a try...
 Originally Posted by REM
Code:
'Net.cls
Option Explicit
Private Const INTERNET_CONNECTION_LAN As Long = &H2
Private Const INTERNET_CONNECTION_MODEM As Long = &H1
Private Const NCBASTAT = &H33
Private Const NCBNAMSZ = 16
Private Const HEAP_ZERO_MEMORY = &H8
Private Const HEAP_GENERATE_EXCEPTIONS = &H4
Private Const NCBRESET = &H32
Private Const MAX_WSADescription = 256
Private Const MAX_WSASYSStatus = 128
Private Const ERROR_SUCCESS As Long = 0
Private Const WS_VERSION_REQD As Long = &H101
Private Const WS_VERSION_MAJOR As Long = WS_VERSION_REQD \ &H100 And &HFF&
Private Const WS_VERSION_MINOR As Long = WS_VERSION_REQD And &HFF&
Private Const MIN_SOCKETS_REQD As Long = 1
Private Const SOCKET_ERROR As Long = -1
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 ' Reserved, must be 0
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 Type HostEnt
hName As Long
hAliases As Long
hAddrType As Integer
hLen As Integer
hAddrList As Long
End Type
Private Type WSADATA
wVersion As Integer
wHighVersion As Integer
szDescription(0 To MAX_WSADescription) As Byte
szSystemStatus(0 To MAX_WSASYSStatus) As Byte
wMaxSockets As Integer
wMaxUDPDG As Integer
dwVendorInfo As Long
End Type
Private Declare Function InternetGetConnectedState _
Lib "wininet.dll" (ByRef lpSFlags As Long, _
ByVal dwReserved As Long) As Long
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
Private Declare Function WSAGetLastError Lib "wsock32.dll" _
() As Long
Private Declare Function WSAStartup Lib "wsock32.dll" _
(ByVal wVersionRequired As Long, lpWSADATA As WSADATA) As Long
Private Declare Function WSACleanup Lib "wsock32.dll" () As Long
Private Declare Function gethostname Lib "wsock32.dll" _
(ByVal szHost As String, ByVal dwHostLen As Long) As Long
Private Declare Function gethostbyname Lib "wsock32.dll" _
(ByVal szHost As String) As Long
'~Function for retrieving the MAC or ethernet address
' from the networked machine. On error, the returned string
' will equal 8 zeros.
Public Function GetEthernet() As String
Dim udtNCB As NCB
Dim bytResponse As Byte
Dim udtASTAT As ASTAT
Dim udtTempASTAT As ASTAT
Dim lngASTAT As Long
Dim strOut As String
Dim x As Integer
udtNCB.ncb_command = NCBRESET
bytResponse = Netbios(udtNCB)
udtNCB.ncb_command = NCBASTAT
udtNCB.ncb_lana_num = 0
udtNCB.ncb_callname = "* "
udtNCB.ncb_length = Len(udtASTAT)
lngASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, udtNCB.ncb_length)
strOut = ""
If lngASTAT Then
udtNCB.ncb_buffer = lngASTAT
bytResponse = Netbios(udtNCB)
CopyMemory udtASTAT, udtNCB.ncb_buffer, Len(udtASTAT)
With udtASTAT.adapt
For x = 0 To 5
strOut = strOut & Right$("00" & Hex$(.adapter_address(x)), 2)
Next x
End With
HeapFree GetProcessHeap(), 0, lngASTAT
End If
GetEthernet = strOut
End Function
Public Function GetIPAddress() As String
Dim sHostName As String * 256
Dim lpHost As Long
Dim Host As HostEnt
Dim dwIPAddr As Long
Dim tmpIPAddr() As Byte
Dim i As Integer
Dim sIPAddr As String
If Not SocketsInitialize() Then
GetIPAddress = ""
Exit Function
End If
If gethostname(sHostName, 256) = SOCKET_ERROR Then
GetIPAddress = ""
'MsgBox "Windows Sockets error " & Str$(WSAGetLastError()) & _
' " has occurred. Unable to successfully get Host Name."
SocketsCleanup
Exit Function
End If
sHostName = Trim$(sHostName)
lpHost = gethostbyname(sHostName)
If lpHost = 0 Then
GetIPAddress = ""
'MsgBox "Windows Sockets are not responding. " & _
' "Unable to successfully get Host Name."
SocketsCleanup
Exit Function
End If
CopyMemory Host, lpHost, Len(Host)
CopyMemory dwIPAddr, Host.hAddrList, 4
ReDim tmpIPAddr(1 To Host.hLen)
CopyMemory tmpIPAddr(1), dwIPAddr, Host.hLen
For i = 1 To Host.hLen
sIPAddr = sIPAddr & tmpIPAddr(i) & "."
Next
GetIPAddress = Mid$(sIPAddr, 1, Len(sIPAddr) - 1)
SocketsCleanup
End Function
Public Function GetIPHostName() As String
Dim sHostName As String * 256
If Not SocketsInitialize() Then
GetIPHostName = ""
Exit Function
End If
If gethostname(sHostName, 256) = SOCKET_ERROR Then
GetIPHostName = "Error in retrieving IP host name!"
Resume Next
'MsgBox "Windows Sockets error " & Str$(WSAGetLastError()) & _
'" has occurred. Unable to successfully get Host Name."
SocketsCleanup
Exit Function
End If
GetIPHostName = Left$(sHostName, InStr(sHostName, Chr(0)) - 1)
SocketsCleanup
End Function
Private Function HiByte(ByVal wParam As Integer)
HiByte = wParam \ &H100 And &HFF&
End Function
Private Function LoByte(ByVal wParam As Integer)
LoByte = wParam And &HFF&
End Function
Private Sub SocketsCleanup()
If WSACleanup() <> ERROR_SUCCESS Then
Resume Next
End If
End Sub
Private Function SocketsInitialize() As Boolean
Dim WSAD As WSADATA
Dim sLoByte As String
Dim sHiByte As String
If WSAStartup(WS_VERSION_REQD, WSAD) <> ERROR_SUCCESS Then
'"The 32-bit Windows Socket is not responding."
SocketsInitialize = False
Exit Function
End If
If WSAD.wMaxSockets < MIN_SOCKETS_REQD Then
'MsgBox "This application requires a minimum of " & _
CStr(MIN_SOCKETS_REQD) & " supported sockets."
SocketsInitialize = False
Exit Function
End If
If LoByte(WSAD.wVersion) < WS_VERSION_MAJOR Or _
(LoByte(WSAD.wVersion) = WS_VERSION_MAJOR And _
HiByte(WSAD.wVersion) < WS_VERSION_MINOR) Then
sHiByte = CStr(HiByte(WSAD.wVersion))
sLoByte = CStr(LoByte(WSAD.wVersion))
'MsgBox "Sockets version " & sLoByte & "." & sHiByte & _
' " is not supported by 32-bit Windows Sockets."
SocketsInitialize = False
Exit Function
End If
SocketsInitialize = True
End Function
Property Get GetOnline() As Boolean
GetOnline = InternetGetConnectedState(0&, 0&)
End Property
Property Get GetStateOnline() As String
If GetOnline Then
GetStateOnline = "Active."
Else
GetStateOnline = "Inactive."
End If
End Property
Public Function ViaLAN() As Boolean
Dim SFlags As Long
'return the flags associated with the connection
Call InternetGetConnectedState(SFlags, 0&)
'True if the Sflags has a LAN connection
ViaLAN = SFlags And INTERNET_CONNECTION_LAN
End Function
Public Function ViaModem() As Boolean
Dim SFlags As Long
'return the flags associated with the connection
Call InternetGetConnectedState(SFlags, 0&)
'True if the Sflags has a modem connection
ViaModem = SFlags And INTERNET_CONNECTION_MODEM
End Function
Now, in a form, or a module.
Code:
Dim netCls As New Net
'To get the local IP, call this. It returns a string containing the IP of your machine.
Msgbox netCls.GetIPAddress
Hope this helps in some way...
Laterz
REM
It seems "As Any" works OK on Window XP (Pentium 4),but crashed on Win7 (Win7 Professinal,Core i5). It is related Windows version or CPU?
I got crash by running this code and some others by declaring HeapFree "lpMem As Any",I Suggest declaring HeapFree "Byval lpMem As Long":
Code:
Dim netCls As New Net
debug.print netCls.GetEthernet
-
Feb 20th, 2011, 09:15 PM
#15
Re: ip address
Really? An 11 year old thread?
-
Feb 20th, 2011, 11:02 PM
#16
Frenzied Member
Re: ip address
 Originally Posted by baja_yu
Really? An 11 year old thread?
I come cross this post because I am searching HeapFree API in VBForum.
-
Feb 21st, 2011, 12:07 AM
#17
Re: ip address
Just because you came across it doesn't mean you need to reply to it. Eleven years... The OP hasn't visited the forum in 9 years.
-
Feb 21st, 2011, 08:04 AM
#18
Frenzied Member
Re: ip address
 Originally Posted by baja_yu
Just because you came across it doesn't mean you need to reply to it. Eleven years... The OP hasn't visited the forum in 9 years.
I have the responsibility to indicate the potential problem which I knew to give others alerting. And,thanks for other participators
-
Mar 3rd, 2011, 06:54 AM
#19
Addicted Member
Re: ip address
Make A new Form Add 3 Textbox Call Them LocalIPAddress, other one called ComputerNameBox, and one called ISPIPAddress then add following code
Code:
Imports System.Net
Imports System.IO
Imports System.Text.RegularExpressions
Public Class Form1
Declare Function SendARP Lib "iphlpapi.dll" Alias "SendARP" (ByVal DestIP As Int32, ByVal SrcIP As Int32, ByVal pMacAddr() As Byte, ByRef PhyAddrLen As Int32) As Int32
declare that then add this code
Code:
Private Sub Network_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GetIPAddress()
InternetProtocolIPAddress()
End Sub
Private Sub InternetProtocolIPAddress()
Dim req As HttpWebRequest = WebRequest.Create("http://whatismyip.com/automation/n09230945.asp")
Dim res As HttpWebResponse = req.GetResponse()
Dim Stream As Stream = res.GetResponseStream()
Dim sr As StreamReader = New StreamReader(Stream)
ISPIPAddress.Text = (sr.ReadToEnd())
End Sub
Private Sub GetIPAddress()
On Error Resume Next
Dim strHostName As String
Dim strIPAddress As String
strHostName = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.Resolve(strHostName).AddressList(0).ToString()
LocalIPAddress.Text = strIPAddress
ComputerNameBox.Text = strHostName
End Sub
Last edited by pillhead2007; Mar 3rd, 2011 at 07:01 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|