1

Konu: WAN IP Adresi Bulma

bi kod da benden smile
daha oncede sorulmustu galiba ama genede yayinlayayim dedim

Kaynak : UT

Visual Fox Pro
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
?GetPublicIpAddress()

 
********************************************************************************
Function GetPublicIpAddress()
********************************************************************************
*!* Returns public IP address
*!* Works under all conditions, routers, proxies, etc.
*!* Works in all Windows versions from 95 to Vista
*!* Downloads a file from a public HTTP server
 
    #Define ERROR_SUCCESS   0
 
    Local;
        m.lcUrl As String, ;
        m.lcFile As String, ;
        m.lcIP As String
 
*!* Generate a random Temp file name:
    m.lcFile = Addbs(Sys(2023)) + Sys(3)
 
*!* Add fake parameter to avoid web caching:
    m.lcUrl = "http://checkip.dyndns.org" + "?" + Sys(3)
 
*!* Set default value to return if API call fails:
    m.lcIP = "0.0.0.0"
 
*!* Attemp to download file:
    If apiURLDownloadToFile(0, m.lcUrl, m.lcFile, 0, 0) = ERROR_SUCCESS Then
*!* Check if file was created:
        If File(m.lcFile) Then
*!* Extract IP from file:
            m.lcIP = Substr(Filetostr(m.lcFile), 77)
            m.lcIP = Left(m.lcIP, Len(m.lcIP) - 16)
            Delete File (m.lcFile)
        Endif
    Endif
 
    Return m.lcIP
Endfunc
 
********************************************************************************
Function apiURLDownloadToFile(m.pCaller, m.szURL, m.szFileName, m.dwReserved, m.lpfnCB)
********************************************************************************
    Declare Integer URLDownloadToFile In urlmon.Dll As apiURLDownloadToFile;
        Integer pCaller, ;
        String szURL, ;
        String szFileName, ;
        Integer dwReserved, ;
        Integer lpfnCB
    Return apiURLDownloadToFile(m.pCaller, m.szURL, m.szFileName, m.dwReserved, m.lpfnCB)
Endfunc
http://www.soykansoft.com/images/twitter.jpghttp://www.soykansoft.com/images/wp.jpghttp://www.soykansoft.com/images/blogger.jpg