1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| * Genel Çıkış IP si
UrlName="http://vbnet.mvps.org/resources/tools/getpublicip.shtml"
oHTTP=NEWOBJECT("winhttp.winhttprequest.5.1")
oHTTP.Open("GET",UrlName,.F.)
oHTTP.Send()
ohTTP.ResponseText
nFirstSingleQuote=AT("'",ohTTP.ResponseText)
nLengthToPull=AT("'",ohTTP.ResponseText,2)-nFirstSingleQuote-1
? SUBSTR(ohTTP.ResponseText,nFirstSingleQuote+1,nLengthToPull)
* Local IP
oWinSock = CreateObject("MSWinsock.Winsock")
?oWinSock.LocalIP
LOCAL IPSocket
crlf=chr(13)+chr(10)
&&local ip adresi
IPSocket = CreateObject("MSWinsock.Winsock")
if type('IPSocket')='O'
IPAddress = IPSocket.LocalIP
localhostname=IPSocket.localhostname
remotehost=IPSocket.remotehost
remotehostip=IPSocket.remotehostip
MessageBox ("Local IP = " + IPAddress+crlf+"local host = "+localhostname;
+crlf+"Remotehost = "+remotehost+crlf+"Remotehostip = "+remotehostip)
else
MessageBox ("Winsock Yuklu Degil!")
ENDIF
* Başka örnek
Declare Integer WSACleanup In ws2_32
Declare String inet_ntoa In ws2_32 Integer in_addr
Declare Integer gethostbyname In ws2_32 String Host
Declare Integer WSAStartup In ws2_32 Integer wVerRq, String lpWSAData
Declare RtlMoveMemory In kernel32 As CopyMemory String @Dest,Integer Src,Integer nLength
CLEA
If WSAStartup(0x202,Repli(Chr(0),512))=0
*? GetIP("network teki bir bilgisayar ismi")
*? GetIP("localhost")
? GetIP(Alltrim(Strextract(Id(),"","#")))
=WSACleanup()
Endif
Function GetIP(cServer)
#Define HOSTENT_SIZE 16
Local nStruct,nSize,cBuffer,nAddr,cIP
nStruct=gethostbyname(cServer)
If nStruct=0
Return "0.0.0.0"
Endif
cBuffer=Repli(Chr(0),HOSTENT_SIZE)
cIP=Repli(Chr(0),4)
=CopyMemory(@cBuffer,nStruct,HOSTENT_SIZE)
=CopyMemory(@cIP,buf2dword(Subs(cBuffer,13,4)),4)
=CopyMemory(@cIP,buf2dword(cIP),4)
Return inet_ntoa(buf2dword(cIP))
Endfunc
Function buf2dword(lcBuffer)
Return Asc(Substr(lcBuffer,1,1))+Bitlshift(Asc(Subs(lcBuffer,2,1)),8)+;
Bitlshift(Asc(Subs(lcBuffer,3,1)),16)+Bitlshift(Asc(Subs(lcBuffer,4,1)),24)
Endfunc |