Rogerio Figueira Posted October 28, 2019 Report Share Posted October 28, 2019 Olá Pessoall, Eu estou precisando que o sistema informe o IP da conexão internet. O IP da rede local eu sei como conseguir, mas da Internet não. Alguém sabe como fazer? Sds. Quote Link to comment Share on other sites More sharing options...
Valdir Posted October 28, 2019 Report Share Posted October 28, 2019 Amigo Rogério... Veja se isso te ajuda. /****************************************************************/ // Rotinas para pegar as Configurações de rede By Vagner Wirts // /****************************************************************/ #include "fivewin.ch" //positions inside array returned by GetNetCardInfo() #define ADP_NAME 1 //An ANSI character string of the name of the adapter. (STRING) #define ADP_DESCRIPTION 2 //An ANSI character string that contains the description //of the adapter. (STRING) #define ADP_ADDRESS 3 //The hardware address for the adapter (STRING) #define ADP_INDEX 4 //The adapter index. //The adapter index may change when an adapter is disabled //and then enabled, or under other circumstances, //and should not be considered persistent.(NUMERIC) #define ADP_TYPE 5 //The adapter type. see define list type (bellow) (NUMERIC) #define ADP_DHCPENABLED 6 //An option value that specifies whether the dynamic host //configuration protocol (DHCP) is enabled for this adapter.(LOGICAL) #define ADP_ADDRESSLIST 7 //The list of IPv4 addresses associated with this adapter(STRING) #define ADP_GATEWAY 8 //The IPv4 address of the gateway for this adapter (STRING) #define ADP_DHCPSERVER 9 //The IPv4 address of the DHCP server for this adapter represented(STRING) #define ADP_HAVEWINS 10 //An option value that specifies whether this adapter uses (LOGICAL) //the Windows Internet Name Service (WINS).(LOGICAL) #define ADP_PRIMARY 11 //the IPv4 address of the primary WINS server #define ADP_SECUNDARY 12 //The IPv4 address of the secondary WINS server //Types #define MIB_IF_TYPE_OTHER 1 //Some other type of network interface. #define MIB_IF_TYPE_ETHERNET 6 //An Ethernet network interface. #define MIB_IF_TYPE_TOKENRING 9 #define MIB_IF_TYPE_PPP 23 //A PPP network interface. #define MIB_IF_TYPE_LOOPBACK 24 //A software loopback network interface. #define MIB_IF_TYPE_SLIP 28 //An ATM network interface. #define IF_TYPE_IEEE80211 71 //An IEEE 802.11 wireless network interface. //Note This adapter type is returned on Windows Vista and later. //On Windows Server 2003 and Windows XP , //an IEEE 802.11 wireless network interface returns an adapter //type of MIB_IF_TYPE_ETHERNET. //---------------------------------------------------// FUNCTION TESTEMAC() Local aConec, lOk:=.T. Local lAchouWiFi := .F. Local lAchouRede := .F. Local i:=1 aConec := GetNetCardInfo() aEval(aConec,<|aCon,nPos| If "WI-FI" $ Upper(aCon[2]) .or. "WIRELES" $ Upper(aCon[2]) .or. "BLUETOOTH" $ Upper(aCon[2]) .or. "HOSTED" $ Upper(aCon[2]) .or. "TeamViewer" $ Upper(aCon[2]) .or. "VPN" $ Upper(aCon[2]) .or. "TAP" $ Upper(aCon[2]) lAchouWiFi := .T. Else If Empty(VAL(aCon[7])) .AND. EMPTY(VAL(aCon[9])) lTemp:=.F. lOk:=.F. MsgStop("Nao foi Detectada a Conexao Ethernet da Rede Com o Servidor...","ATENCAO...") Else lAchouRede := .T. Endif Endif >) ? "Rede Interna : "+Iif(lAchouRede,""," Não")+ " Achou",; "Wi-Fi : "+Iif(lAchouWiFi,""," Não")+ " Achou",; xbrowse( GetNetCardInfo() ) return nil //--------------- FIM DO PROGRAMA ------------------------// Essa Rotina foi criada pelo Mestre Vagner Wirts. Ela pega as informações da rede. Repare que nas colunas G,H e I estão as informações dos Ips e Getway. Acredito que você deve usar as informações das Colunas H ou I. Abraços. Rogerio Figueira 1 Quote Link to comment Share on other sites More sharing options...
rochinha Posted October 29, 2019 Report Share Posted October 29, 2019 Amiguinhos, Acho que você vai precisar de PINGA Valdir, vagner and Rogerio Figueira 3 Quote Link to comment Share on other sites More sharing options...
vagner Posted October 30, 2019 Report Share Posted October 30, 2019 Não perdendo a brincadeira, Rochinha, além da PINGA, limão açúcar e gelo Abraços aferra, Valdir and rochinha 3 Quote Link to comment Share on other sites More sharing options...
Rogerio Figueira Posted October 30, 2019 Author Report Share Posted October 30, 2019 Olá pessoal, obrigado pelas contribuições. Eu ainda não tive tempo de testar a solução passada pelo Valdir nem a Pinga do Rochinha. Tentei agora a solução do Sistem , que parece a mais simples de implementar, mas apresenta um erro, não tenho a função WebConnect:Unresolved external '_HB_FUN_WEBCONNECT' Eu utilizo o FiveWin 1402 e o xHarbour 1.2.3 . []´s Quote Link to comment Share on other sites More sharing options...
rochinha Posted November 6, 2019 Report Share Posted November 6, 2019 Amiguinhos, Rogerio Figueira Dentro da PINGA tem um ingrediente, getIPExtern Rogerio Figueira 1 Quote Link to comment Share on other sites More sharing options...
Rogerio Figueira Posted November 12, 2019 Author Report Share Posted November 12, 2019 Pessoal, quero agradecer a colaboração de todos e postar aqui a solução baseada na dica do Rochinha e outra que descobri na documentação do MySQL. Desta forma eu pego o IP do cliente da última conexão ao banco MySQL, isto é, conecto ao banco de dados e logo a seguir executo esta verificação: TRY CONNECT bServer HOST alltrim(host) ; USER alltrim(usuario) ; PASSWORD alltrim(senha) ; PORT nPort ; FLAGS nFlags; DATABASE "information_schema" CATCH oErr MsgInfo( oErr:Description ) RETURN NIL END oQry:= bServer:Query("SELECT host FROM information_schema.processlist WHERE ID = connection_id( ) LIMIT 0 , 10") userIP := oQry:host bServer:end() //========================================= Aqui usando a dica do Rochinha a partir do código do PINGA: #include "dll.ch" static xdll 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) //return subst(alltrim(xml),1,len(alltrim(xml))-5) METHOD End() CLASS TdWebService FreeLib32(xDll) return nil 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 InternetReadFile(hFile As 7, @sBuffer As 8, lNumBytesToRead As 7, @lNumberOfBytesRead As 7) As 7 PASCAL Lib xDll //========================== function getIPExtern( _site_ ) local _IPExtern_ ws:=TdWebService():new() _IPExtern_ := ws:OpenWS(_site_) ws:end() msginfo(_IPExtern_) return //=========================== getIPExtern("http://representantes.info/meuip.php") //========================= Conforme a dica do Sistem acima, o código do arquivo meuip.php é este: <?php $ip = getenv("REMOTE_ADDR");echo "$ip" ?> //============================= Sds. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.