Page 1 of 3
Testing a valid IP address? ( SOLVED! )
Posted: Mon Oct 27, 2008 1:03 pm
by JC
Exists a way to testing if some IP address is valid?
I have tried this, but not works:
Code: Select all
FUNCTION isConnected( cNetEnd )
LOCAL lConected := .F.
inetInit()
aHosts := inetGetHosts( cNetEnd )
lConected := ( len( aHosts ) > 0 )
inetCleanUp()
RETURN( lConected )
Get valid IP
Posted: Mon Oct 27, 2008 1:45 pm
by ukoenig
Hello JC,
Here is a tool, to get the IP Informations.
rename getip._xe to getip.exe
Get IP shows the Hostname and the IP-Adresses.
You can copy the informations to the clipboard and show it
in the Systray if you want.
It needs VB-Runtime 5
http://www.pflegeplus.com/fw_downloads/getip._xe
Regards
Uwe
Posted: Mon Oct 27, 2008 1:47 pm
by JC
Uwe,
Thank you for this tip!
But, exists a way to do it with my application? Internally, via source?
IP
Posted: Mon Oct 27, 2008 1:52 pm
by ukoenig
Hello JC,
I don't know for the moment, but you
can call it with using WINEXEC inside your application.
Regards
Uwe
Posted: Mon Oct 27, 2008 2:08 pm
by JC
Uwe,
Your executable returns to me the machine name and the ip address. Very cool!
Would get that return on getip.exe without open it?
IP-Info
Posted: Mon Oct 27, 2008 2:11 pm
by ukoenig
Hello JC,
some Infos from the help-file :
You can read from clipboard inside your application !!!
What Is Get IP?
Get IP is a small program which easily shows your hostname and all your local IP addresses. This information can then be copied to the clipboard for future use in any other application.
Many people can make sure of Get IP, especially gamers. How many times have you needed to give someone your IP address so you can play a game online? Probably a number of times. Now, with Get IP you can view your hostname and all your local IP addresses by simply loading Get IP. What's more, you can make Get IP automatically copy this information to clipboard, and then either minimise itself to your System tray or Task Bar for quick and easy access, or close the program entirely, so in a flash you have the information you want about your Internet connection.
Options
The Get IP options screen allows you to configure Get IP in every detail, including what the program does when it loads, and what it does when it has loaded.
Click on the section of the options menu you are interested in below for a detailed description on what the section does as how it changes the program.
Note that you can reset the options to their default values by clicking the 'Reset to defaults' button. You will be asked to confirm this action before the settings are reset.
Load Get IP When Windows Starts
When this option is ticked Get IP will load when Windows starts. This can be useful if you want your IP address copied to clipboard every time Windows starts.
If you want Get IP to load when Windows starts and then minimise to the System Tray, you need to select that option in the 'Options - Loading' section.
Allow Get IP To Run In The Background
When this option is ticked it will allow Get IP to run in the System Tray should you close the program. If you select 'Exit' from the 'Information' menu Get IP will always exit, whether this option is ticked or not. This option only applied when the 'X' is clicked in the top right hand corner of the main window.
Regards
Uwe
Posted: Mon Oct 27, 2008 2:25 pm
by JC
Uwe,
Now, works fine
But, We still have one problem: Will be necessary installing this application to execute my source function... always!
Start application
Posted: Mon Oct 27, 2008 2:34 pm
by ukoenig
Hello JC,
maybe just using a BATCH-File ( i didn't test it ) ?
A other way : a small exe with just 2 Winexec-calls.
START.bat
GetIP.exe
Myprog.exe
Regards
Uwe
Posted: Mon Oct 27, 2008 2:39 pm
by Armando
JC:
Perhaps this can help you
Code: Select all
WSAStartup()
MsgInfo(GetHostByName("www.google.com.mx"))
WSACleanUp()
Regards
Posted: Mon Oct 27, 2008 2:44 pm
by JC
Uwe and Armando,
Thanks!
I made, for local subnet, with this method:
? empty( getHostByAddress( "127.0.0.1" ) )
? empty( getHostByAddress( "17.0.5.102" ) )
GETIP
Posted: Mon Oct 27, 2008 2:45 pm
by ukoenig
Armando,
Like JC explained :
I understand : he needs the IP-informations, before he starts
his application ?.
Regards
Uwe
Posted: Mon Oct 27, 2008 2:55 pm
by JC
Uwe,
Actually, I want to see if an IP location of my local network is available ... if the machine is turned on, for example.
The function getHostByAddress( cNetIP ) is the best way to do it?
If returns empty... is because the IP is not valid!
Look for valid IP
Posted: Mon Oct 27, 2008 5:09 pm
by ukoenig
Hello JC,
I will check, if there is something in Win-API to use.
Regards
Uwe
Posted: Mon Oct 27, 2008 5:18 pm
by Rochinha
JC,
GETHOSTBYNAME( YourIPString ) work´s?
Posted: Mon Oct 27, 2008 5:28 pm
by JC
Rochinha wrote:JC,
GETHOSTBYNAME( YourIPString ) work´s?
Rochinha,
Funcionou com a função getHostByAddress( cNetAddress )... ela resolve o IP retornando o nome do endereço. Se for um IP local, ele retorna o nome da máquina (netbios name).
Quando o IP está inválido ou não existe um "site" ou máquina com o o IP informado... ela retorna branco.
Aí bastou testar se o retorno está em branco ou não!