Bueno esa era mi duda estoy haciendo un programa con vb6 y queria saber como se hace para que dsp de apretar un boton te salga la ip que uno tiene osea modem normal sin router probe con el Winsock algo asi y no me andubo
No se mucho de VB pero no lo podrias hacer abriendo la CMD y escribiendo "ipconfig" :huh:
si pero me gustaria que se viera de otra forma... ej: se abre una ventanita y dice tu ip es 123.123.213
hola, estoy intentando crear el script que necesitas (en CMD), pero con mi metodo necesitarias de la herramienta "sed.exe", te la dejo en megaupload para que no busques.
sería algo así:
@echo off
ipconfig >> %systemdrive%\ip.txt
type "%systemdrive%\ip.txt" | find /i "ipv4" >> %systemdrive%\ip2.txt
@SED.EXE "/IPv4/ s/IPv4. . . . . . . . . . . . . . /Ip es/Ig" %systemdrive%\ip2.txt > %systemdrive%\ip3.txt
echo+
type "%systemdrive%\ip3.txt"
del /f "%systemdrive%\ip.txt" & del /f "%systemdrive%\ip2.txt" & del /f "%systemdrive%\ip3.txt"
pause>nul
aunque lo mismo se podria hacer sin el SED, pero para mi es mucho más fácil así, aunque no consigo quitar la palabra "dirección" porque lleva acento y el comando sed no la reconoce bien así, lo he podido dejar mas o menos como tu querias mira:
(http://s4.subirimagenes.com/imagen/3624257331114242.png)
Bueno al menos con eso tienes una idea.
Aquí el "SED.exe" >> http://www.megaupload.com/?d=8T3LZBS1 (está comprimido en winrar, lo ejecutas para instalarlo en windows, o descomprimes e instalas manualmente)
saludos.
Prueba a cambiar esta linea:
echo+
echo Tu & type %systemdrive%\ip3.txt"
creo que esta es la sección de vb.... no de batch...
salu2!
vos que queres que te salga, la Ip Public o la Ip local?
bue para obtener la Ip public, yo siempre hice asi:
Modulo BAS:
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_FLAG_RELOAD = &H80000000
Const sURL = "http://checkip.dyndns.org/"
Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Public Function TheIP()
Dim pIP() As String
Dim nose As String
Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
sBuffer = Space(1000)
hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
InternetReadFile hFile, sBuffer, 1000, Ret
InternetCloseHandle hFile
InternetCloseHandle hOpen
pIP = Split(Trim(sBuffer), ": ")
nose = Left(pIP(1), Len(pIP(1)) - 16)
TheIP = nose
End Function
y para obtener la Ip local: Obtener la Ip - Función api GetIpAddrTable (http://www.recursosvisualbasic.com.ar/htm/listado-api/api-55-ip-GetIpAddrTable.htm)
Cita de: fary94 en 27 Noviembre 2009, 18:28 PM
creo que esta es la sección de vb.... no de batch...
salu2!
Bueno, contesté porque este post primero estaba en la sección batch y ahora lo han movido aquí, además se que a chris le sirvió un batch para otro boton, y le serviria un batch para esto tambien :).
saludos.
No creo que sea mejor solución que la de xkiz pero podrías utilizar el control winsock y llamar a msgbox winsock1.localip
Una tercer opcion seria WMI, pero a veces sirve y a veces not
Option Explicit
Private Sub Form_Load()
Me.AutoRedraw = True: Me.Height = 6045: Me.Width = 4300
LoadControl
End Sub
Sub LoadControl()
If WMI_disponible() Then
'Me.Print "TU SISTEMA TIENE WMI", vbOKOnly + vbInformation, "WMI"
getWMI_Info
Else
Me.Print "TU SISTEMA NO TIENE WMI", vbOKOnly + vbExclamation, "WMI"
End If
End Sub
Public Function WMI_disponible() As Boolean
Dim WMI As Object
On Error Resume Next
Set WMI = GetObject("winmgmts:")
WMI_disponible = (Err.Number = 0)
End Function
Private Sub getWMI_Info()
Dim oAdapters As Object
Dim oAdapter As Object
On Error GoTo Fehler_WMI
Me.Print "----------------------------------------------------------------------------------------------"
Set oAdapters = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
Dim ctlip1 As String: Dim ctlip2 As String
For Each oAdapter In oAdapters
With oAdapter
'Me.Cls '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Join(.IPAddress) <> ctlip1 Then
Me.Print "NOMBRE:" & vbTab & vbTab & vbTab & Environ$("computername")
Me.Print "DIRECCION IP:" & vbTab & vbTab & vbTab & Join(.IPAddress)
Me.Print "MASCARA DE SUBRED:" & vbTab & Join(.IPSubnet)
'If Not IsNull(.DefaultIPGateway) Then
Me.Print "PUERTA DE ENLACE:" & vbTab & vbTab & Join(.DefaultIPGateway)
'End If
Me.Print "DIRECCION MAC:" & vbTab & vbTab & .MACAddress
Me.Print "DNS:" & vbTab & vbTab & vbTab & vbTab & .DNSHostName
'If .WINSPrimaryServer <> "" Then
Me.Print "WINS 1:" & vbTab & vbTab & vbTab & .WINSPrimaryServer
'End If
'If .WINSSecondaryServer <> "" Then
Me.Print "WINS 2:" & vbTab & vbTab & vbTab & .WINSSecondaryServer
'End If
Me.Print ":---------------------------------------------------------------------------------------------"
ctlip1 = Join(.IPAddress)
End If
End With
Next
On Error GoTo 0
Exit Sub
Fehler_WMI:
MsgBox "Error: " & Err.Number & vbTab & Err.Description, vbCritical
Resume Next
End Sub
para mi es mejor usar api que ActiveX, por eso puse lo que puse. jeje
Pitoloko si esa es tu ip,eres de ONO :xD
Cita de: ɟoǝ-Ʀ00Ƭ en 29 Noviembre 2009, 12:42 PM
Pitoloko si esa es tu ip,eres de ONO :xD
Si...Tu tambien por lo q parece, he! ;D
p.d: Donde te has metido crhis? xD
[quote a
uthor=pitoloko link=topic=275934.msg1357882#msg1357882 date=1259597583]
Cita de: ɟoǝ-Ʀ00Ƭ en 29 Noviembre 2009, 12:42 PM
Pitoloko si esa es tu ip,eres de ONO :xD
Si...Tu tambien por lo q parece, he! ;D
p.d: Donde te has metido crhis? xD
[/quote]
Me dices ami pitoloko?
esque me llamo christian tambien e.e
PD:si soy de ONO..segun ellos 12MB reales..si la mitad los otros virtuales