Cek Koneksi Internet, Cari IP Host Name dan IP Adress

Hallo-hallo maaf ini posting pertama setelah lama berkutat dengan pekerjaan
Berikut ini adalah Source code yang berfungsi untuk mengetahui IP Host Name dan IP Adress komputer kita dan juga kode untuk mengetahui status komputer kita terhubung dengan internet atau tidak.Sumber penulisan dari Buku Jurus Hacking dengan Visual Basic Oleh Dianse Hermanu penerbit Neomerdia Press dan dari situs Http://Planet-Source-Code.Com
Untuk posting selanjutnya mungkin source code untuk mengetahui IP Adress komputer lain yang terhubung dengan komputer kita dan mengerjai komputernya he..he…Langsung saja
Yang dibutuhkan dalam proyek ini adalah :
- 2 label dengan property name LblCekMyIP1 dan LblCekMyIP2
- 1 timer dengan property name Timer1, iNTERVAL = 1000
- Winsock1, untuk menambahkan Winsock1 pada toolbox maka dengan cara klik kanan pada toolbox pilih component dan centang microsoft winsock control 6.0
- status bar dengan property name SB, untuk menambahkan status bar pada toolbox caranya sama dengan winsock tetapi pilih windows common controls 6.0(sp6)
  Kemudian setelah status bar ditambahkan dalam form maka klik kanan status bar tersebut pilih property dan pada tab panel pilih angka 2 pada textbox Autosize.
- 1 modul untuk source code cek koneksi internet dan ip adress/Host name
- 1 form

Semoga bermanfaat, terimakasih.

Download File di site Tempat Download dan Upload File Gratis Join 4Shared Now!
‘==================================
‘COPY PASTEKAN KODE DI BAWAH INI PADA FORM
Private Sub Form_Load()
Timer1.Enabled = True
LblCekMyIP1 = “IP Host Name: ” & GetIPHostName
LblCekMyIP2 = “IP Address: ” & GetIPAddress()
End Sub

Private Sub Timer1_Timer()
If InternetGetConnectedState( 0&,  0& ) = 1 Then
SB.Panels(1).Text = “Status: Terhubung dengan Internet”
Else
SB.Panels(1).Text = “Status: Tidak terhubung dengan Internet”
End If
End Sub
‘LETAKKAN sOURCE CODE CEK KONEKSI INTERNET DAN CEK IP Adress komputer/HOST NAME DIBAWAH INI PADA MODUL

‘cek koneksi internet
Public Declare Function InternetGetConnectedState Lib “wininet.dll” (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long

‘———CEK IP Adress komputer dan HOST NAME—–
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” Alias “gethostbyname” (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)

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. Host Name tidak dapat ditampilkan.”
SocketsCleanup
Exit Function
End If
 sHostName = Trim$(sHostName)
 lpHost = GetHostByName(sHostName)
 
 If lpHost = 0 Then
 GetIPAddress = “”
 MsgBox “Socket Windows tidak memberikan respon. ” & “Host Name tidak dapat ditampilkan.”
 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. Host Name tidak dapat ditampilkan.”
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 terjadi dalam 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 “Socket Windows 32-bit tidak respon”
SocketsInitialize = False
Exit Function
End If
 If WSAD.wMaxSockets = MIN_SOCKETS_REQD Then
 MsgBox “Aplikasi ini membutuhkan minimum ” & CStr(MIN_SOCKETS_REQD) & ” Socket yang support.”
 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 “Versi Socket ” & sLoByte & “.” & sHiByte & ” tidak didukung oleh Socket Windows 32-bit.”
 SocketsInitialize = False
Exit Function
End If
 SocketsInitialize = True
End Function

~ oleh Joko di/pada Mei 18, 2008.

2 Tanggapan to “Cek Koneksi Internet, Cari IP Host Name dan IP Adress”

  1. yes sedot ahhh, trims

  2. jin julian no 37

Tinggalkan Balasan