Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Need to know your IP address?

Thread Tools
 
Search this Thread
 
Old 12 November 2002, 04:33 PM
  #1  
dsmith
Scooby Regular
Thread Starter
 
dsmith's Avatar
 
Join Date: Mar 1999
Posts: 4,518
Likes: 0
Received 0 Likes on 0 Posts
Post

Didnt mean to denigrate the dev work involved

Wot I meant was ... if you're (for example) behind a small router that does internet dial-up and hides your local lan behind a dynamic NAT address - will it report your local LAN address (as would ipconfig) or does it do something deeply funky in conjunction with something on the Internet and report your externally visible address.

Deano

[Edited by dsmith - 12/11/2002 4:37:39 PM]
Old 11 December 2002, 10:52 AM
  #2  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

I just wrote this app for my Dad so we can file share.



It shows your IP address and machine name and sits unobtrusively on the top of the screen (but can be dragged). You can also copy the text (how many times do you have to write the damn thing down because the app won't let you copy it )

DL it here.

Fosters
Old 11 December 2002, 11:13 AM
  #3  
DJ Dunk
Moderator
Support Scoobynet!
iTrader: (5)
 
DJ Dunk's Avatar
 
Join Date: Nov 2001
Location: Not all those who wander are lost
Posts: 17,863
Received 0 Likes on 0 Posts
Thumbs up

Top work mate. Any chance of a zoomed piccy ?
Old 11 December 2002, 11:19 AM
  #4  
rik1471
Scooby Regular
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

Nice one. Just what I needed
Old 11 December 2002, 11:43 AM
  #5  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

Old 11 December 2002, 11:52 AM
  #6  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

What a dork! Just changed my computer name and ip address, so don't even bother
Old 11 December 2002, 12:35 PM
  #7  
ripmaze
Scooby Regular
 
ripmaze's Avatar
 
Join Date: Aug 2002
Posts: 135
Likes: 0
Received 0 Likes on 0 Posts
Arrow

unobtrusively
It's using 5MB of my precious RAM

I find it easier to type "ipconfig" at a command prompt and (if you're in "QuickEdit Mode") then click and drag over the text you want and press Enter to copy it. Nice idea though Fosters.

How do you file share with the IP address?
Old 11 December 2002, 12:49 PM
  #8  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

4megs on mine, I imagine it's VB runtimes adding their 2 penneth. I only have 200megs free ram

It took 20 minutes to write and doesn't use winsock! much more satisfying than typing in IPConfig!

Ok, I'm a geek.
Old 11 December 2002, 01:40 PM
  #9  
DominicA
Scooby Regular
 
DominicA's Avatar
 
Join Date: Aug 2000
Posts: 1,771
Likes: 0
Received 0 Likes on 0 Posts
Question

why did you need to do this??? have you seen dyn-dns ..... you can get small apps that update their records online ..... you could then use your domain name...
Old 11 December 2002, 02:57 PM
  #10  
Puff The Magic Wagon!
Moderator
Support Scoobynet!
iTrader: (2)
 
Puff The Magic Wagon!'s Avatar
 
Join Date: May 2000
Location: From far, far away...
Posts: 16,978
Received 15 Likes on 9 Posts
Cool

Fosters

Theres better things to be doing with your "free" time & bandwidth, you know

Nice though

Old 11 December 2002, 03:01 PM
  #11  
Crispin
Scooby Regular
 
Crispin's Avatar
 
Join Date: Jan 2001
Posts: 534
Likes: 0
Received 0 Likes on 0 Posts
Post

n1 Fosters - People need to appreciate a good API cowboy when they see one....... yes sireeee
Old 11 December 2002, 03:28 PM
  #12  
dsmith
Scooby Regular
Thread Starter
 
dsmith's Avatar
 
Join Date: Mar 1999
Posts: 4,518
Likes: 0
Received 0 Likes on 0 Posts
Post

Does it work if you're Natted behind a router ? (or is it literally just a neat gui for "ipconfig")

Deano
Old 11 December 2002, 04:27 PM
  #13  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

I would hope it'd work behind a router and no it's not a posh front to ipConfig
Old 11 December 2002, 05:58 PM
  #14  
ChristianR
Scooby Regular
iTrader: (1)
 
ChristianR's Avatar
 
Join Date: May 2001
Location: Europe
Posts: 6,329
Likes: 0
Received 1 Like on 1 Post
Post

it will just show your local ip information/name taken from your network adaptor...

for internet one, why not just go to www.whatismyipaddress.com ?
Old 11 December 2002, 10:26 PM
  #15  
dsmith
Scooby Regular
Thread Starter
 
dsmith's Avatar
 
Join Date: Mar 1999
Posts: 4,518
Likes: 0
Received 0 Likes on 0 Posts
Post

If fosters had some funky code I was going to ask to steal it for a project I'm doing

There are, I know, plenty of webistes to tell me my address (including one I had setup myself to reveal any transparent caching) - at some point I've got to write a script to pull the details and extract the IP address. I was hoping someone else (who isnt a programming retard like myself) had done the work....

Deano
Old 11 December 2002, 10:39 PM
  #16  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

here you go:

================================ module code
Option Explicit

Public Const MAX_WSADescription = 256
Public Const MAX_WSASYSStatus = 128
Public Const ERROR_SUCCESS As Long = 0
Public Const WS_VERSION_REQD As Long = &H101
Public Const WS_VERSION_MAJOR As Long = WS_VERSION_REQD \ &H100 And &HFF&
Public Const WS_VERSION_MINOR As Long = WS_VERSION_REQD And &HFF&
Public Const MIN_SOCKETS_REQD As Long = 1
Public Const SOCKET_ERROR As Long = -1

Public Type HOSTENT
hName As Long
hAliases As Long
hAddrType As Integer
hLen As Integer
hAddrList As Long
End Type

Public 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

Public Declare Function WSAGetLastError Lib "WSOCK32.DLL" () As Long

Public Declare Function WSAStartup Lib "WSOCK32.DLL" _
(ByVal wVersionRequired As Long, lpWSADATA As WSADATA) As Long

Public Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long

Public Declare Function gethostname Lib "WSOCK32.DLL" _
(ByVal szHost As String, ByVal dwHostLen As Long) As Long

Public Declare Function gethostbyname Lib "WSOCK32.DLL" _
(ByVal szHost As String) As Long

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)



========================================= Form Code
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Declare Function SetWindowPos Lib "user32" (ByVal _
hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Sub SetTopmostWindow(ByVal hWnd As Long, Optional topmost As Boolean = True)
Const HWND_NOTOPMOST = -2
Const HWND_TOPMOST = -1
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
SetWindowPos hWnd, IIf(topmost, HWND_TOPMOST, HWND_NOTOPMOST), 0, 0, 0, 0, _
SWP_NOMOVE + SWP_NOSIZE

End Sub
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 = ""
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

Public Function HiByte(ByVal wParam As Integer)

HiByte = wParam \ &H100 And &HFF&

End Function

Public Function LoByte(ByVal wParam As Integer)
LoByte = wParam And &HFF&
End Function



Public Sub SocketsCleanup()

If WSACleanup() <> ERROR_SUCCESS Then
MsgBox "Socket error occurred in Cleanup."
End If

End Sub



Public 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
MsgBox "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

'must be OK, so lets do it
SocketsInitialize = True

End Function



Private Sub Form_Load()
Text1 = GetIPAddress
Text2 = GetIPHostName
End Sub




Old 11 December 2002, 11:04 PM
  #17  
Puff The Magic Wagon!
Moderator
Support Scoobynet!
iTrader: (2)
 
Puff The Magic Wagon!'s Avatar
 
Join Date: May 2000
Location: From far, far away...
Posts: 16,978
Received 15 Likes on 9 Posts
Cool

Oi you!!!

I thought you were spending some "quality time" tonight
Old 11 December 2002, 11:07 PM
  #18  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

had to wait for that fecking D/L!
which is D/Led btw.
will get productive tomorrow.
Old 11 December 2002, 11:11 PM
  #19  
Puff The Magic Wagon!
Moderator
Support Scoobynet!
iTrader: (2)
 
Puff The Magic Wagon!'s Avatar
 
Join Date: May 2000
Location: From far, far away...
Posts: 16,978
Received 15 Likes on 9 Posts
Thumbs up





Old 13 December 2002, 03:49 PM
  #20  
Andy Mid.
Scooby Regular
 
Andy Mid.'s Avatar
 
Join Date: Apr 1999
Posts: 403
Likes: 0
Received 0 Likes on 0 Posts
Post

A couple of years ago, my bro wrote a tiny app to do this. It tells you your IP and then, if you click the button, it copies the number to your clipboard so that you can paste it into ICQ messages etc before you host a game.

It's 32kb and can be downloaded here http://www.wob****e.com/spoonip.zip
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
oilman
Trader Announcements
15
01 October 2015 11:55 AM
oilman
Trader Announcements
0
23 September 2015 12:35 PM
EvilBevel
ScoobyNet General
2
01 December 2000 10:11 AM
Chip
ScoobyNet General
6
24 April 2000 01:31 PM



Quick Reply: Need to know your IP address?



All times are GMT +1. The time now is 03:18 AM.