Currently i'm using
Code: Select all
if CHDIR(computer1)then...
Code: Select all
if CHDIR(computer1)then...
Code: Select all
Print Launch$("cmd.exe /C ping -n 1 MyOtherNotebook")
Code: Select all
#pragma once
#include once "winpackagefamily.bi"
#define _INC_WINAPIFAMILY
const WINAPI_FAMILY_PC_APP = 2
const WINAPI_FAMILY_PHONE_APP = 3
const WINAPI_FAMILY_SYSTEM = 4
const WINAPI_FAMILY_SERVER = 5
const WINAPI_FAMILY_DESKTOP_APP = 100
const WINAPI_FAMILY_APP = WINAPI_FAMILY_PC_APP
const WINAPI_FAMILY = WINAPI_FAMILY_DESKTOP_APP
const WINAPI_PARTITION_DESKTOP = WINAPI_FAMILY = WINAPI_FAMILY_DESKTOP_APP
const WINAPI_PARTITION_APP = ((WINAPI_FAMILY = WINAPI_FAMILY_DESKTOP_APP) orelse (WINAPI_FAMILY = WINAPI_FAMILY_PC_APP)) orelse (WINAPI_FAMILY = WINAPI_FAMILY_PHONE_APP)
const WINAPI_PARTITION_PC_APP = (WINAPI_FAMILY = WINAPI_FAMILY_DESKTOP_APP) orelse (WINAPI_FAMILY = WINAPI_FAMILY_PC_APP)
const WINAPI_PARTITION_PHONE_APP = WINAPI_FAMILY = WINAPI_FAMILY_PHONE_APP
const WINAPI_PARTITION_SYSTEM = (WINAPI_FAMILY = WINAPI_FAMILY_SYSTEM) orelse (WINAPI_FAMILY = WINAPI_FAMILY_SERVER)
const WINAPI_PARTITION_PHONE = WINAPI_PARTITION_PHONE_APP
#define WINAPI_FAMILY_PARTITION(Partitions) (Partitions)
#define _WINAPI_DEPRECATED_DECLARATION __declspec(deprecated("This API cannot be used in the context of the caller's application type."))
Code: Select all
#pragma once
#include once "winapifamily.bi"
#define __SENSAPI_H__
const NETWORK_ALIVE_LAN = &h00000001
const NETWORK_ALIVE_WAN = &h00000002
const NETWORK_ALIVE_AOL = &h00000004
const NETWORK_ALIVE_INTERNET = &h00000008
type tagQOCINFO
dwSize as DWORD
dwFlags as DWORD
dwInSpeed as DWORD
dwOutSpeed as DWORD
end type
type QOCINFO as tagQOCINFO
type LPQOCINFO as tagQOCINFO ptr
#define IsDestinationReachable IsDestinationReachableA
'' TODO: BOOL APIENTRY IsDestinationReachableA( LPCSTR lpszDestination, LPQOCINFO lpQOCInfo );
'' TODO: BOOL APIENTRY IsDestinationReachableW( LPCWSTR lpszDestination, LPQOCINFO lpQOCInfo );
'' TODO: BOOL APIENTRY IsNetworkAlive( LPDWORD lpdwFlags );
There is: IcmpSendEchoxbgtc wrote:thanks but I'm aware of ping but wanna see if there's a coding way
Code: Select all
#include "win\winsock2.bi"
function GetSiteAddress(stuff as string="www.freebasic.net") as string
dim as WSADATA _wsadate
dim as in_addr addr
dim as hostent ptr res
dim as integer i = 0
WSAStartup(MAKEWORD(2,2),@_wsadate)
res = gethostbyname(stuff)
if res then
print stuff
while (res->h_addr_list[i] <> 0)
addr.s_addr = *(cast (ulong ptr,res->h_addr_list[i]))
print "IP Address: ";*inet_ntoa(addr)
i+=1
wend
WSACleanup()
else
print "website error?"
end if
if stuff="www.freebasic.net" and res=0 then return "offline"
if stuff="www.freebasic.net" and res<>0 then return "online"
end function
print GetSiteAddress
print
print GetSiteAddress ("www.freepascal.org")
sleep
Hey, that works much better than IcmpSendEcho, even for my 'TheOtherNotebook'! Thanxalot, dodicat...dodicat wrote:You want it in FreeBASIC code, then use the freeBASIC website to tell you.
(As a bonus you get an IP address)
Code: Select all
#ifdef __FB_WIN32__
#INCLUDE once "win/winsock2.bi"
#Else
#INCLUDE once "crt/netdb.bi"
#INCLUDE once "crt/sys/socket.bi"
#INCLUDE once "crt/netinet/in.bi"
#INCLUDE once "crt/arpa/inet.bi"
#INCLUDE once "crt/unistd.bi"
#EndIf
function GetSiteAddress(stuff as string="www.freebasic.net") as string
dim as in_addr addr
dim as hostent ptr res
dim as integer i = 0
#ifdef __FB_WIN32__
dim as WSADATA _wsadate
If( WSAStartup(MAKEWORD(2, 2), @_wsadate) <> 0 ) Then Return 1
#EndIf
res = gethostbyname(stuff)
if res then
print stuff
while (res->h_addr_list[i] <> 0)
addr.s_addr = *(cast (ulong ptr, res->h_addr_list[i]))
print "IP Address: "; *inet_ntoa(addr)
i+=1
wend
#ifdef __FB_WIN32__
WSACleanup()
#EndIf
else
print "website error? "; stuff
end if
if stuff="www.freebasic.net" and res=0 then return "offline"
if stuff="www.freebasic.net" and res<>0 then return "online"
end function
print GetSiteAddress
print
print GetSiteAddress ("www.freepascal.org")
print GetSiteAddress ("www.notawebsite123.456")
print "end"
sleep
Code: Select all
#include "win\winsock2.bi"
function CO(comp as string) as byte
dim as WSADATA giger
dim as hostent ptr cp
WSAStartup(MAKEWORD(2,2),@giger)
cp=gethostbyname(comp)
if cp then return 1 else return 0
WSACleanup()
end function
do
if CO("C128") then ?"Franco:ON" else ?"Franco:OFF"
if CO("CASPER") then ?"Abbo:ON" else ?"Abbo:OFF"
if CO("LAPTOP") then ?"Lappy:ON" else ?"Lappy:OFF"
sleep 2000
loop while inkey=""
(if you know that it is local, you can reduce the timeout with -w <ms>)jj2007 wrote:Not sure how to do this in FB, but it works:If the "other" notebook is present, it takes milliseconds, otherwise about 3 seconds. There is a thread here, but it doesn't seem to apply to Windows.Code: Select all
Print Launch$("cmd.exe /C ping -n 1 MyOtherNotebook")
Thanks. I had tested that before and saw no effect. Now I retried, and got it to work (no idea what was different...). Interesting:marcov wrote:(if you know that it is local, you can reduce the timeout with -w <ms>)
Code: Select all
Esecuzione di Ping TheOtherNotebook.blabla.telecomitalia.it [192...] con 32 byte di dati:
Risposta da 192...: byte=32 durata<1ms TTL=128
Statistiche Ping per 192...:
Pacchetti: Trasmessi = 1, Ricevuti = 1,
Persi = 0 (0% persi),
Tempo approssimativo percorsi andata/ritorno in millisecondi:
Minimo = 0ms, Massimo = 0ms, Medio = 0ms