Hace tiempo en el foro de gambas-es se abrió un hilo sobre como saber la IP pública. La solución que dieron fue la de conocerla desde una web como http://whatismyip.org/ o como http://dynupdate.no-ip.com/ip.php
Y yo por mi parte contribuí a hacer un pequeño script gambas (gbs2) para crear un icono en el área de notificaciones que mostrase la IP pública.
Pues bien, aquí les dejo el script.
Y para más info vean el hilo http://www.gambas-es.org/viewtopic.php?f=5&t=1827
#!/usr/bin/env gbs2
' myipgb.gbs - Saber la IP pública
' $ ./myipgb.gbs [tiempo en ms]
USE "gb.gui"
USE "gb.form"
USE "gb.net"
USE "gb.net.curl"
PUBLIC F AS NEW Form
PUBLIC TimerIP AS Timer
PUBLIC TrayIP AS TrayIcon
PUBLIC mTray AS Menu
PUBLIC mIP AS Menu
PUBLIC mCopy AS Menu
PUBLIC mQuit AS Menu
PUBLIC HttpClientIP AS HttpClient
PUBLIC SUB Main()
mTray = NEW Menu(F, TRUE)
mTray.Visible = FALSE
mIP = NEW Menu(mTray) AS "mIP"
mIP.Caption = "IP"
mCopy = NEW Menu(mTray) AS "mCopy"
mCopy.Picture = Stock["16/copy"]
mCopy.Caption = "Copy IP"
mQuit = NEW Menu(mTray) AS "mQuit"
mQuit.Picture = Stock["16/quit"]
mQuit.Caption = "Quit"
TrayIP = NEW TrayIcon AS "TrayIP"
TrayIP.Picture = Stock["16/network"]
TrayIP.Visible = TRUE
HttpClientIP = NEW HttpClient AS "HttpClientIP"
HttpClientIP.URL = "
http://dynupdate.no-ip.com/ip.php"
HttpClientIP.Async = TRUE
HttpClientIP.Get
TimerIP = NEW Timer AS "TimerIP"
IF Val(Application.Args[1]) THEN
TimerIP.Delay = Val(Application.Args[1])
ELSE
TimerIP.Delay = 1800000 ' 30 min
ENDIF
TimerIP.Start
END
PUBLIC SUB TimerIP_Timer()
HttpClientIP.Get
END
PUBLIC SUB mQuit_Click()
PRINT "QUIT"
QUIT
END
PUBLIC SUB TrayIP_Menu()
mTray.Popup
END
PUBLIC SUB HttpClientIP_Finished()
DIM sIP AS String
IF Lof(HttpClientIP) THEN
READ #HttpClientIP, sIP, Lof(HttpClientIP)
END IF
PRINT Time(Now), sIP
mIP.Caption = sIP
END
PUBLIC SUB HttpClientIP_Error()
PRINT "ERROR"
mIP.Caption = "IP"
END
PUBLIC SUB mCopy_Click()
Clipboard.Copy(mIP.Caption)
END
PUBLIC SUB mIP_Click()
mIP.Caption = "IP"
HttpClientIP.Get
END
Saludos!
No hay comentarios:
Publicar un comentario
Hey you!
Deja un comentario! va?!