Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
Site İp Öğrenme (vb6)
#1
Formumuza
2 adet Text
1 adet command button
Ve birde Modül ekledikten sonra bu kodları Form General kısmına yapıştırıyoruz..

'Form Kısmı'

Kod:
Private Sub Command1_Click()
Dim sHostName As String
If SocketsInitialize() Then
sHostName = Text1.Text
Text2.Text = GetIPFromHostName(sHostName)
SocketsCleanup
Else
MsgBox "Windows Sockets For 32 bit Windows " & _
"Is Not successfully responding."
End If
End Sub

'Modül Kısmına bu kodları yapıştırıyoruz..
'


Kod:
Option Explicit
Private Declare Function WSAStartup Lib "wsock32" _
(ByVal VersionReq As Long, _
WSADataReturn As WSADATA) As Long

Private Declare Function WSACleanup Lib "wsock32" () As Long

Private Declare Function inet_addr Lib "wsock32" _
(ByVal s As String) As Long

Private Declare Function gethostbyaddr Lib "wsock32" _
(haddr As Long, _
ByVal hnlen As Long, _
ByVal addrtype As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(xDest As Any, _
xSource As Any, _
ByVal nbytes As Long)

Private Declare Function lstrlen Lib "kernel32" _
Alias "lstrlenA" _
(lpString As Any) As Long
Public Const IP_SUCCESS As Long = 0
Public Const MAX_WSADescription As Long = 256
Public Const MAX_WSASYSStatus As Long = 128
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

Private Const WSADescription_Len As Long = 256
Private Const WSASYS_Status_Len As Long = 128
Private Const AF_INET As Long = 2

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 Long
wMaxUDPDG As Long
dwVendorInfo As Long
End Type

Private Declare Function gethostbyname Lib "wsock32" _
(ByVal hostname As String) As Long



Private Declare Function lstrlenA Lib "kernel32" _
(lpString As Any) As Long






Public Function SocketsInitialize() As Boolean

Dim WSAD As WSADATA
Dim success As Long

SocketsInitialize = WSAStartup(WS_VERSION_REQD, WSAD) = IP_SUCCESS

End Function


Public Sub SocketsCleanup()

If WSACleanup() <> 0 Then
MsgBox "Windows Sockets Error occurred In Cleanup.", vbExclamation
End If

End Sub


Public Function GetIPFromHostName(ByVal sHostName As String) As String



Dim nbytes As Long
Dim ptrHosent As Long
Dim ptrName As Long
Dim ptrAddress As Long
Dim ptrIPAddress As Long
Dim sAddress As String

sAddress = Space$(4)

ptrHosent = gethostbyname(sHostName & vbNullChar)

If ptrHosent <> 0 Then


ptrAddress = ptrHosent + 12

CopyMemory ptrAddress, ByVal ptrAddress, 4
CopyMemory ptrIPAddress, ByVal ptrAddress, 4
CopyMemory ByVal sAddress, ByVal ptrIPAddress, 4

GetIPFromHostName = IPToText(sAddress)

End If

End Function


Private Function IPToText(ByVal IPAddress As String) As String

IPToText = CStr(Asc(IPAddress)) & "." & _
CStr(Asc(Mid$(IPAddress, 2, 1))) & "." & _
CStr(Asc(Mid$(IPAddress, 3, 1))) & "." & _
CStr(Asc(Mid$(IPAddress, 4, 1)))

End Function
Beğenenler:
#2
eline sağlık exciting
İnsɑnlɑr değişmez değişen tek şey şɑrtlɑr ve çıkɑrlɑr...
Beğenenler:

Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  Site İp Öğrenme ;) PikaPuf 25 1,388 08-03-2016, Saat: 23:55
Son Yorum: Baromeen
  İp adres ve ipv4 adresi öğrenme (noob style vb6) gmjackal01 2 362 20-08-2015, Saat: 17:01
Son Yorum: Ayar
Anahtar Kelimeler

Site İp Öğrenme (vb6) indir, Site İp Öğrenme (vb6) Videosu, Site İp Öğrenme (vb6) Online izle, Site İp Öğrenme (vb6) Bedava indir, Site İp Öğrenme (vb6) Yükle, Site İp Öğrenme (vb6) Hakkında, Site İp Öğrenme (vb6) Nedir, Site İp Öğrenme (vb6) Free indir, Site İp Öğrenme (vb6) Oyunu, Site İp Öğrenme (vb6) Download


1 Ziyaretçi