Code:
'dlltest.bas 'compiled with pbcc 4.04 'example of program to show how to use use p2cntrydll.dll ' #COMPILE EXE #DIM ALL DECLARE FUNCTION Ip2cntry LIB "Ip2cntrydll.dll" ALIAS "Ip2Cntry" (BYVAL sip AS STRING) AS STRING DECLARE FUNCTION InitializeIp2cntry LIB "Ip2cntrydll.dll" ALIAS "InitializeIp2Cntry" (BYVAL sdatafileipcountry AS STRING) AS LONG FUNCTION PBMAIN () AS LONG LOCAL ip2cntryrunning AS LONG LOCAL suseipcountrydatabase AS STRING LOCAL a AS STRING LOCAL b AS STRING 'most of the time if a failure was created in opening the database, meaning ip2cntryrunning=0 'the statements below the initializeip2cntry would not be run, but i am doing so you can see the results ' suseipcountrydatabase=TRIM$(COMMAND$) IF LEN(suseipcountrydatabase)=0 THEN PRINT "place an compatiable ip2cntryd database file on the command line" PRINT "ex: c:\temp\ip2cntry.dat" PRINT "file format:" PRINT $DQ+"## source of ip to country list"+$DQ PRINT $DQ+"33996344"+$DQ+","+$DQ+"33996351"+$DQ+","+$DQ+"GB"+$DQ+","+$DQ+"United Kingdom"+$DQ PRINT $DQ+"50331648"+$DQ+","+$DQ+"68257567"+$DQ+","+$DQ+"US"+$DQ+","+$DQ+"United States"+$DQ PRINT $DQ+"68257568"+$DQ+","+$DQ+"68257599"+$DQ+","+$DQ+"CA"+$DQ+","+$DQ+"Canada"+$DQ PRINT $DQ+"68257600"+$DQ+","+$DQ+"68259583"+$DQ+","+$DQ+"US"+$DQ+","+$DQ+"United States"+$DQ PRINT $DQ+"68259584"+$DQ+","+$DQ+"68259599"+$DQ+","+$DQ+"CA"+$DQ+","+$DQ+"Canada"+$DQ PRINT $DQ+"68259600"+$DQ+","+$DQ+"68296775"+$DQ+","+$DQ+"US"+$DQ+","+$DQ+"United States"+$DQ PRINT $DQ+"68296776"+$DQ+","+$DQ+"68296783"+$DQ+","+$DQ+"MX"+$DQ+","+$DQ+"Mexico"+$DQ PRINT $DQ+"68296784"+$DQ+","+$DQ+"68298887"+$DQ+","+$DQ+"US"+$DQ+","+$DQ+"United States"+$DQ SLEEP 10000 EXIT FUNCTION END IF PRINT "requesting ip2cntrydll.dll to use the database "+suseipcountrydatabase ip2cntryrunning=InitializeIp2cntry(suseipcountrydatabase) ' note: if ip2cntryrunning = 0 then ip country database did not load in ip2cntrydll.dll and there was an error ' note: if ip2cntryrunning <> 0 then ip country database did load successfull in the ip2cntrydll.dll and there was an error PRINT "the return of ip2cntryrunning is"+STR$(ip2cntryrunning) IF ip2cntryrunning=0 THEN PRINT PRINT "ip2cntrydll.dll cannot find or use "+suseipcountrydatabase PRINT SLEEP 5000 END IF b="101.10" a=ip2cntry(b) PRINT b+" "+a b="101.102.103.104" a=ip2cntry(b) PRINT PRINT b+" "+a b="221.208.208.87" a=ip2cntry(b) PRINT PRINT b+" "+a b="24.64.120.236" a=ip2cntry(b) PRINT PRINT b+" "+a b="77.97.151.233" a=ip2cntry(b) PRINT PRINT b+" "+a b="124.178.139.154" a=ip2cntry(b) PRINT PRINT b+" "+a b="217.121.34.239" a=ip2cntry(b) PRINT PRINT b+" "+a b="118.175.125.235" a=ip2cntry(b) PRINT PRINT b+" "+a SLEEP 10000 END FUNCTION
Leave a comment: