Поиск не работает, в Чаво (http://vbnet.ru/unfaq/showall.asp) такого вопроса нет, а в рубрике "Примеры" после долгого поиска не нашел. Поэтому зря вы так на меня нападаете. Может пример где-то и есть, но он очень хитро запрятан
А пример просто как определить IP я и так знаю. Но дело в том, что не у всех при подключении к инету IP меняется. У тех, кто пользуется, например, кабелем, он не меняется.
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
 ataBindingBehavior = 0 'vbNone
 ataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ata"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Private Declare Function RasEnumConnections Lib "RasApi32.dll" Alias "RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Long
Private Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias "RasGetConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As Long
Private Declare Function GetProfStr Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal sSection As String, ByVal sKey As Any, ByVal sDefault As String, ByVal sValue As String, ByVal nSize As Long, ByVal sFileName As String) As Long
Private Const RAS95_MaxEntryName = 256
Private Const RAS95_MaxDeviceType = 16
Private Const RAS95_MaxDeviceName = 32
Private Type RASCONN95
dwSize As Long
hRasCon As Long
szEntryName(RAS95_MaxEntryName) As Byte
szDeviceType(RAS95_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
Private Type RASCONNSTATUS95
dwSize As Long
RasConnState As Long
dwError As Long
szDeviceType(RAS95_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
Private sConName As String, bIsConnected As Boolean, sDeviceName As String, sDeviceType As String
Public Sub UpdateData()
 im TRasCon(255) As RASCONN95, Tstatus As RASCONNSTATUS95, TempBuffer As String
 im lg As Long, lpcon As Long
TRasCon(0).dwSize = 412
lg = 256 * TRasCon(0).dwSize
Call RasEnumConnections(TRasCon(0), lg, lpcon)
Tstatus.dwSize = 160
Call RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
If Tstatus.RasConnState = &H2000 Then bIsConnected = True
TempBuffer = StrConv(TRasCon(0).szDeviceType, vbUnicode)
sDeviceType = Left(TempBuffer, InStr(TempBuffer, vbNullChar) - 1)
End Sub
Public Function IsConnected() As Boolean
IsConnected = bIsConnected
End Function
Public Function GetConName() As String
GetConName = sConName
End Function
Public Function GetDeviceType() As String
GetDeviceType = sDeviceType
End Function
Public Function GetDeviceName() As String
GetDeviceName = sDeviceName
End Function
Public Function GetNumInfo() As String
GetNumInfo = "ALL"
End Function
Public Function GetDescription(lng As String) As String
GetDescription = GetINI("Lib", "escription", vbNullString, IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\" & App.EXEName & lng & ".ini"
End Function
Private Function GetINI(strSection As String, strKey As String, strDefault As String, strFileName As String) As String
 im uname As String, slength As Long
uname = Space(512)
slength = GetProfStr(strSection, strKey, strDefault, uname, 512, strFileName)
uname = Left(uname, slength)
If Left(uname, 6) = " " Then GetINI = Right(uname, slength - 6) Else GetINI = uname
End Function
1.PB
#Compile Dll "RasApi.dll"
#Dim All
#Include "RAS32.INC"
#Include "WIN32API.INC"
Global tStatus As RASCONNSTATUS, TRasCon() As RASCONN
Global g_hInstance As Long
Sub UpdateData Alias "UpdateData") Export
 im lg As Long, lpcon As Long
lg = 256 * TRasCon(0).dwSize
Call RasEnumConnections(TRasCon(0), lg, lpcon)
End Sub
Function IsConnected Alias "IsConnected") Export As Long
 im tStatus As RASCONNSTATUS
Call RasGetConnectStatus(TRasCon(0).hRasConn, Tstatus)
If Tstatus.RasConnState = %RASCS_DONE Then Function = 1& Else Function = 0&
End Function
Function GetConName Alias "GetConName") Export As String
Function = TRasCon(0).szEntryName
End Function
Function GetDeviceName Alias "GetDeviceName") Export As String
GetDeviceName = TRasCon(0).szDeviceName
End Function
Function GetDeviceType Alias "GetDeviceType") Export As String
GetDeviceType = LCase$(TRasCon(0).szDeviceType)
End Function
Function GetNumInfo Alias "GetNumInfo") Export As String
Function = "ALL"
End Function
Function GetDescr Alias "GetDescription"ByVal lng As String) Export As String
Local iniFile As Asciiz * %MAX_PATH, lRes As Long, outStr As Asciiz * &H400
include c:\\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\rasapi32.inc
include c:\masm32\include\oleaut32.inc
GetConName proc
lea eax, TRasCon.szEntryName
ret
GetConName endp
GetDeviceName proc
lea eax, TRasCon.szDeviceName
ret
GetDeviceName endp
GetDeviceType proc
invoke CharLower, addr TRasCon.szDeviceType
ret
GetDeviceType endp
GetNumInfo proc
.data
all db "ALL",0
.code
lea eax, all
ret
GetNumInfo endp
GetDescription proc uses edi esi lng:DWORD
Local iniFile[MAX_PATH]:BYTE, outStr[400h]:BYTE
.data
iniext db ".ini",0
inicapt db "Lib",0
inikey db "escription",0
.code
invoke GetModuleFileName, hInstance, addr iniFile, MAX_PATH
lea edi, iniFile ; Установка указателей
lea esi, lng ; На идентификатор языка
invoke lstrlen, addr iniFile ; Получение длитнны пути
sub eax, 4h ; Отрезаем .ini
add edi, eax
xor eax, eax ; путем занесения нуля
mov [edi], eax ; в нужное место...
; Доводим до ума путь к иньке
invoke lstrcat, addr iniFile, lng
invoke lstrcat, addr iniFile, addr iniext
; ##########################################################################
End start
2.VB
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
 ataBindingBehavior = 0 'vbNone
 ataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ata"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" Alias "InternetGetConnectedStateExA" (ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, ByVal dwNameLen As Long, ByVal dwReserved As Long) As Long
Private Declare Function GetProfStr Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal sSection As String, ByVal sKey As Any, ByVal sDefault As String, ByVal sValue As String, ByVal nSize As Long, ByVal sFileName As String) As Long
Private Const INTERNET_CONNECTION_MODEM = &H1&
Private Const INTERNET_CONNECTION_LAN = &H2&
Private sConName As String, bIsConnected As Boolean, sDeviceName As String, sDeviceType As String
Public Sub UpdateData()
 im dwFlags As Long, Msg As String, lPos As Long
sConName = String$(513, 0)
If InternetGetConnectedStateEx(dwFlags, sConName, 512, 0& Then
bIsConnected = True
If dwFlags And INTERNET_CONNECTION_LAN Then
sDeviceType = "LAN"
ElseIf dwFlags And INTERNET_CONNECTION_MODEM Then
sDeviceType = "Modem"
End If
Else
bIsConnected = False
sConName = ""
sDeviceName = ""
sDeviceType = ""
End If
End Sub
Public Function IsConnected() As Boolean 'Подключены ли мы к инету
IsConnected = bIsConnected
End Function
Public Function GetConName() As String 'Получаем имя текущего соединения
GetConName = sConName
End Function
Public Function GetDeviceType() As String 'Тип устройства
GetDeviceType = sDeviceType
End Function
Public Function GetDeviceName() As String 'Имя устройства
GetDeviceName = sDeviceName
End Function
Public Function GetNumInfo() As String 'Служебная информация для программы
GetNumInfo = "IE5"
End Function
Public Function GetDescription(lng As String) As String
GetDescription = GetINI("Lib", "escription", vbNullString, IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\" & App.EXEName & lng & ".ini"
End Function
Private Function GetINI(strSection As String, strKey As String, strDefault As String, strFileName As String) As String
 im uname As String, slength As Long
uname = Space(512)
slength = GetProfStr(strSection, strKey, strDefault, uname, 512, strFileName)
uname = Left(uname, slength)
If Left(uname, 6) = " " Then GetINI = Right(uname, slength - 6) Else GetINI = uname
End Function
2.PB
#Compile Dll "IGetConState.dll"
#Dim All
#Include "WININET.INC"
#Include "WIN32API.INC"
Global sConName As Asciiz * 513, bIsConnected As Byte, sDeviceType As String
Global g_hInstance As Long
Sub UpdateData Alias "UpdateData") Export
 im dwFlags As Long, Msg As String, lPos As Long
If Not InternetGetConnectedStateEx(dwFlags, sConName, 512, 0& = 0& Then
bIsConnected = 1&
If (dwFlags And %INTERNET_CONNECTION_LAN) = %INTERNET_CONNECTION_LAN Then
sDeviceType = "LAN"
ElseIf (dwFlags And %INTERNET_CONNECTION_MODEM) = %INTERNET_CONNECTION_MODEM Then
sDeviceType = "Modem"
End If
Else
bIsConnected = 0&
sConName = ""
sDeviceType = ""
End If
End Sub
Function IsConnected Alias "IsConnected") Export As Long
IsConnected = bIsConnected
End Function
Function GetConName Alias "GetConName") Export As String
Function = sConName
End Function
Function GetDeviceName Alias "GetDeviceName") Export As String
GetDeviceName = ""
End Function
Function GetDeviceType Alias "GetDeviceType") Export As String
GetDeviceType = sDeviceType
End Function
Function GetNumInfo Alias "GetNumInfo") Export As String
Function = "IE5"
End Function
Function GetDescr Alias "GetDescription"lng As String) Export As String
Local iniFile As Asciiz * %MAX_PATH, lRes As Long, outStr As Asciiz * &H400
Function GetData Alias "GetData"ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As String, _
ByVal lParam As Long) Export As String
Select Case uMsg
Case &H1 ' UpdateData
Call UpdateData()
Function = "1"
Exit Function
Case &H2 ' IsConnected
Function = Str$(IsConnected())
Exit Function
Case &H3 ' GetConName
Function = GetConName
Exit Function
Case &H4 ' GetDeviceName
Function = GetDeviceName
Exit Function
Case &H5 ' GetDeviceType
Function = GetDeviceType
Exit Function
Case &H6 ' GetNumInfo
Function = GetNumInfo
Exit Function
Case &H7 ' GetDesctr
Function = GetDescr(wParam)
Exit Function
End Select
End Function
' ----------------------------- Инициализация dll библиотеки -----------------------------------
Function DllMain(ByVal hInstance As Long, ByVal Reason As Long, ByVal Reserved As Long) As Long
If Reason = %DLL_PROCESS_ATTACH Then g_hInstance = hInstance
Function = 1&
End Function
include c:\\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\wininet.inc
include c:\masm32\include\oleaut32.inc
GetConName proc
lea eax, sConName
ret
GetConName endp
GetDeviceName proc
lea eax, sDeviceName
ret
GetDeviceName endp
GetDeviceType proc
lea eax, sDeviceType
ret
GetDeviceType endp
GetNumInfo proc
.data
all db "IE5",0
.code
lea eax, all
ret
GetNumInfo endp
GetDescription proc uses edi esi lng:DWORD
Local iniFile[MAX_PATH]:BYTE, outStr[400h]:BYTE
.data
iniext db ".ini",0
inicapt db "Lib",0
inikey db "escription",0
.code
invoke GetModuleFileName, hInstance, addr iniFile, MAX_PATH
lea edi, iniFile ; Установка указателей
lea esi, lng ; На идентификатор языка
invoke lstrlen, addr iniFile ; Получение длитнны пути
sub eax, 4h ; Отрезаем .ini
add edi, eax
xor eax, eax ; путем занесения нуля
mov [edi], eax ; в нужное место...
; Доводим до ума путь к иньке
invoke lstrcat, addr iniFile, lng
invoke lstrcat, addr iniFile, addr iniext
; ##########################################################################
End start
3.VB
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
 ataBindingBehavior = 0 'vbNone
 ataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ata"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Private Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" (lpRasconn As Any, lpcb As Long, lpcConnections As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type VBRASCONN
hRasConn As Long
sEntryName As String
sDeviceType As String
sDeviceName As String
sPhonebook As String
lngSubEntry As Long
guidEntry(15) As Byte
End Type
Private Declare Function GetProfStr Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal sSection As String, ByVal sKey As Any, ByVal sDefault As String, ByVal sValue As String, ByVal nSize As Long, ByVal sFileName As String) As Long
Private sConName As String, bIsConnected As Boolean, sDeviceName As String, sDeviceType As String
Public Sub UpdateData()
 im rtn As Long, b() As Byte, ras_i As Long
 im aLens As Variant, dwSize As Long
 im lpcb As Long, lpConns As Long
 im aVBRasConns() As VBRASCONN
For ras_i = 0 To 3
dwSize = aLens(ras_i)
Call CopyMemory(b(0), dwSize, &H4): lpcb = 4
rtn = RasEnumConnections(b(0), lpcb, lpConns)
If Not rtn = 632 And Not rtn = 610 Then Exit For
Next
If lpConns = 0 Then Exit Sub
ReDim aVBRasConns(lpConns - 1)
For ras_i = 0 To lpConns - 1
With aVBRasConns(ras_i)
Call CopyMemory(.hRasConn, b(ras_i * dwSize + 4), &H4)
If dwSize = 32& Then
Call CopyByteToTrimmedString(.sEntryName, b(ras_i * dwSize + 8), 21&
Else
Call CopyByteToTrimmedString(.sEntryName, b(ras_i * dwSize + 8), 257&
Call CopyByteToTrimmedString(.sDeviceType, b(ras_i * dwSize + 265), 17&
Call CopyByteToTrimmedString(.sDeviceName, b(ras_i * dwSize + 282), 129&
If dwSize > 412& Then
Call CopyByteToTrimmedString(.sPhonebook, b(ras_i * dwSize + 411), 260&
Call CopyMemory(.lngSubEntry, b(ras_i * dwSize + 672), 4)
If dwSize > 676& Then Call CopyMemory(.guidEntry(0), b(ras_i * dwSize + 676), 16)
End If
End If
bIsConnected = True
sConName = .sEntryName
sDeviceName = .sDeviceName
sDeviceType = .sDeviceType
End With
Next
End Sub
Public Function IsConnected() As Boolean 'Подключены ли мы к инету
IsConnected = bIsConnected
End Function
Public Function GetConName() As String 'Получаем имя текущего соединения
GetConName = sConName
End Function
Public Function GetDeviceType() As String 'Тип устройства
GetDeviceType = sDeviceType
End Function
Public Function GetDeviceName() As String 'Имя устройства
GetDeviceName = sDeviceName
End Function
Public Function GetDescription(lng As String) As String
GetDescription = GetINI("Lib", "escription", vbNullString, IIf(Right$(App.Path, 1) = "\", App.Path, App.Path & "\" & App.EXEName & lng & ".ini"
End Function
Private Function GetINI(strSection As String, strKey As String, strDefault As String, strFileName As String) As String
 im uname As String, slength As Long
uname = Space$(512)
slength = GetProfStr(strSection, strKey, strDefault, uname, 512, strFileName)
uname = Left$(uname, slength)
If Left$(uname, 6) = " " Then GetINI = Right$(uname, slength - 6) Else GetINI = uname
End Function
Private Sub CopyByteToTrimmedString(strToCopyTo As String, bPos As Byte, lngMaxLen As Long)
 im strTemp As String, lngLen As Long
strTemp = String$(lngMaxLen + 1, 0)
Call CopyMemory(ByVal strTemp, bPos, lngMaxLen)
lngLen = InStr(strTemp, Chr$(0)) - 1
strToCopyTo = Left$(strTemp, lngLen)
End Sub
3.PB
#Compile Dll "AuthGCS.dll"
#Dim All
#Include "RAS32.INC"
#Include "WIN32API.INC"
Global g_hInstance As Long
Global lpRasConn() As RASCONN
Global sBuffer As String
Function WinErrorMsg(ByVal dError As Dword) As String
Local pBuffer As Asciiz Ptr
Local ncbBuffer As Dword
nRet = RasEnumConnections(lpRasConn(0), lpcb, lpcConnections)
If Not nRet = 0 Then
MsgBox WinErrorMsg(nRet)
End If
End Sub
Function IsConnected Alias "IsConnected") Export As Long
Function = Not (lpRasConn(0).hRasConn = 0&
End Function
Function GetConName Alias "GetConName") Export As String
Function = lpRasConn(0).szEntryName
End Function
Function GetDeviceName Alias "GetDeviceName") Export As String
GetDeviceName = lpRasConn(0).szDeviceName
End Function
Function GetDeviceType Alias "GetDeviceType") Export As String
GetDeviceType = LCase$(lpRasConn(0).szDeviceTYPE)
End Function
Function GetNumInfo Alias "GetNumInfo") Export As String
Function = "All"
End Function
Function GetDescr Alias "GetDescription"lng As String) Export As String
Local iniFile As Asciiz * %MAX_PATH, lRes As Long, outStr As Asciiz * &H400
Function GetData Alias "GetData"ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As String, _
ByVal lParam As Long) Export As String
Select Case uMsg
Case &H1 ' UpdateData
Call UpdateData()
Function = "1"
Exit Function
Case &H2 ' IsConnected
Function = Str$(IsConnected())
Exit Function
Case &H3 ' GetConName
Function = GetConName
Exit Function
Case &H4 ' GetDeviceName
Function = GetDeviceName
Exit Function
Case &H5 ' GetDeviceType
Function = GetDeviceType
Exit Function
Case &H6 ' GetNumInfo
Function = GetNumInfo
Exit Function
Case &H7 ' GetDesctr
Function = GetDescr(wParam)
Exit Function
End Select
End Function
' ----------------------------- Инициализация dll библиотеки -----------------------------------
Function DllMain(ByVal hInstance As Long, ByVal Reason As Long, ByVal Reserved As Long) As Long
If Reason = %DLL_PROCESS_ATTACH Then
g_hInstance = hInstance
End If
include c:\\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\rasapi32.inc
include c:\masm32\include\oleaut32.inc
GetConName proc
lea eax, lpRasConn.szEntryName
ret
GetConName endp
GetDeviceName proc
lea eax, lpRasConn.szDeviceName
ret
GetDeviceName endp
GetDeviceType proc
invoke CharLower, addr lpRasConn.szDeviceType
ret
GetDeviceType endp
GetNumInfo proc
.data
all db "ALL",0
.code
lea eax, all
ret
GetNumInfo endp
GetDescription proc uses edi esi lng:DWORD
Local iniFile[MAX_PATH]:BYTE, outStr[400h]:BYTE
.data
iniext db ".ini",0
inicapt db "Lib",0
inikey db "escription",0
.code
invoke GetModuleFileName, hInstance, addr iniFile, MAX_PATH
lea edi, iniFile ; Установка указателей
lea esi, lng ; На идентификатор языка
invoke lstrlen, addr iniFile ; Получение длитнны пути
sub eax, 4h ; Отрезаем .ini
add edi, eax
xor eax, eax ; путем занесения нуля
mov [edi], eax ; в нужное место...
; Доводим до ума путь к иньке
invoke lstrcat, addr iniFile, lng
invoke lstrcat, addr iniFile, addr iniext
куда уж проще, бери любой код копируя (для VB) в класс, создавай, используй... для PB - в модуль, для ассемблера - в inc/asm - без разницы Можешь и в dll'ку это чудо откомпилировать и вызывать... в чем проблемма-то...
Это же 3 способа на 3 языках, по отдельности каждый из них маленький! Т.е. то что тут это в 9 раз больше того что тебе необходимо!
Private Declare Function IsNetworkAlive Lib "SENSAPI.DLL" (ByRef lpdwFlags As Long) As Long
Private Sub Form_Load()
Dim Ret As Long,Res As Long
Res = IsNetworkAlive(Ret)
If Res = 1 And Ret = 2 Then MsgBox "Есть соединение"
End Sub