|
| |
Пост N: 334
Зарегистрирован: 17.06.10
|
|
Отправлено: 31.05.15 17:55. Заголовок: Function Ping(Destin..
Function Ping(DestinationAddress) local IcmpHandle,Replicas local RequestData:="Testando ping",; RequestSize:=15,; RequestOptions:="",; ReplyBuffer:=space(278),; ReplySize:=278,; Timeout:=150 && Milisegundos de espera default DestinationAddress := "0.0.0.0" DestinationAddress:=left(alltrim(DestinationAddress)+space(15),15) IcmpHandle:=IcmpCreateFile() Replicas:=IcmpSendEcho(IcmpHandle,; inet_addr(DestinationAddress),; RequestData,; RequestSize,0,; ReplyBuffer,; ReplySize,; Timeout) IcmpCloseHandle(IcmpHandle) CursorWait() // Resultados nInetAddr := inet_addr(DestinationAddress) cNetName := NETNAME() cgetHostName := getHostName() //, Valtype( getHostName() ) cgetNetCardID := getNetCardID() cIPExtern := getIPExtern( "http://www.5volution.com/meuip.asp" ) WsaStartUp() // Very Important cgetHostByName_NetName:= getHostByName( NETNAME() ) cgetHostByAddress_IP := getHostByAddress( DestinationAddress ) cgetHostByName_Google := getHostByName( "www.google.com" ) WsaCleanUp() // Very Important /* ? "function inet_addr: " + str(inet_addr(DestinationAddress)),; "function NetName: " + cNetName,; "function getHostName: " + cgetHostName,; "function getNetCardID: " + cgetNetCardID,; "function getHostByName with NetName: " + cgetHostByName_NetName,; "function getHostByAddress with IP: " + cgetHostByAddress_IP,; "function getHostByName with Google site: " + cgetHostByName_Google ** "function getPIExtern in my website: " + cIPExtern if Replicas > 0 msginfo("Machine "+alltrim(DestinationAddress)+" exist") else msginfo("Machine "+alltrim(DestinationAddress)+" not existe") endif */ return iif(Replicas>0,.T.,.F.) function getIPExtern( _site_ ) local _IPExtern_ ws:=TdWebService():new() _IPExtern_ := ws:OpenWS( _site_ ) ws:end() return _IPExtern_ CLASS TdWebService DATA hOpen DATA sbuffer HIDDEN DATA xDLL HIDDEN METHOD New(buffersize) CONSTRUCTOR METHOD OpenWS(url) METHOD End() ENDCLASS METHOD New(conexion,buffersize) CLASS TdWebService DEFAULT buffersize:=64000 ::sbuffer:=buffersize xDll:=LoadLib32("wininet.dll") ::hOpen = InternetOpen("TdWebService", 1,,, 0) RETURN Self METHOD OpenWS(url) CLASS TdWebService local hFile,ret,xml hFile = InternetOpenUrl(::hOpen, url,"",0,,0) xml:=space(::sbuffer) InternetReadFile(hFile, @xml, ::sbuffer, @Ret) return alltrim(xml) METHOD End() CLASS TdWebService FreeLib32(xDll) return nil DLL32 FUNCTION InternetOpen( cApp as LPSTR, n1 AS DWORD, n2 AS LPSTR, n3 AS LPSTR,; n4 AS DWORD ) AS LONG PASCAL ; FROM "InternetOpenA" LIB xDll Dll32 FUNCTION InternetReadFile(hFile As 7, @sBuffer As 8, lNumBytesToRead As 7, @lNumberOfBytesRead As 7) As 7 PASCAL Lib xDll Dll32 FUNCTION InternetOpenUrl(hInternetSession As 7, lpszUrl As 8, lpszHeaders As 8, dwHeadersLength As 7, dwFlags As 7, dwContext As 7) As 7 FROM "InternetOpenUrlA" PASCAL Lib xDll DLL32 FUNCTION InternetCloseHandle( hSession AS LONG ) AS BOOL PASCAL LIB xDll DLL32 FUNCTION InternetConnect( hInternet AS LONG, cServerName AS LPSTR, nServerPort AS LONG, cUserName AS LPSTR, cPassword AS LPSTR, nService AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS LONG PASCAL FROM "InternetConnectA" LIB xDll DLL32 FUNCTION FTPGETFILE( hConnect AS LONG, cRemoteFile AS LPSTR, cNewFile AS LPSTR, nFailIfExists AS LONG, nFlagsAndAttribs AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS BOOL PASCAL FROM "FtpGetFileA" LIB xDll DLL32 FUNCTION FTPPUTFILE( hConnect AS LONG, cLocalFile AS LPSTR, cNewRemoteFile AS LPSTR, nFlags AS DWORD, @nContext AS PTR ) AS BOOL PASCAL FROM "FtpPutFileA" LIB xDll DLL32 FUNCTION InternetWriteFile( hFile AS LONG, cBuffer AS LPSTR, lSize AS LONG, @nSize AS PTR ) AS BOOL PASCAL LIB xDll DLL32 FUNCTION FtpOpenFile( hFTP AS LONG, cRemoteFile AS LPSTR, n1 AS LONG, n2 AS LONG, n3 AS LONG ) AS LONG PASCAL FROM "FtpOpenFileA" LIB xDll DLL32 FUNCTION InternetSetFilePointer( hFile AS LONG, nDistanceToMove AS LONG, nReserved AS LPSTR, nSeekMethod AS LONG, @nContext AS PTR ) AS BOOL PASCAL LIB xDll DLL32 FUNCTION FtpFindFirstFile( hFTP AS LONG, cMask AS LPSTR, @cWin32DataInfo AS LPSTR, n1 AS LONG, n2 AS LONG ) AS LONG PASCAL FROM "FtpFindFirstFileA" LIB xDll DLL32 FUNCTION InternetFindNextFile( hFTPDir AS LONG, @cWin32DataInfo AS LPSTR ) AS BOOL PASCAL FROM "InternetFindNextFileA" LIB xDll DLL32 FUNCTION WSAGetLastError() AS _INT PASCAL FROM "WSAGetLastError" LIB "wsock32.dll" DLL32 FUNCTION inet_addr(cIP AS STRING) AS LONG PASCAL FROM "inet_addr" LIB "wsock32.dll" DLL32 FUNCTION IcmpCreateFile() AS LONG PASCAL FROM "IcmpCreateFile" LIB "icmp.dll" DLL32 FUNCTION IcmpCloseHandle(IcmpHandle AS LONG) AS LONG PASCAL FROM "IcmpCloseHandle" LIB "icmp.dll" DLL32 FUNCTION IcmpSendEcho(IcmpHandle AS LONG,; DestinationAddress AS LONG,; RequestData AS STRING,; RequestSize AS LONG,; RequestOptions AS LONG,; ReplyBuffer AS LPSTR,; ReplySize AS LONG,; Timeout AS LONG) AS LONG PASCAL FROM "IcmpSendEcho" LIB "icmp.dll"
|