Alaska Software Inc. - Ping from XBase++
Username: Password:
AuthorTopic: Ping from XBase++
Jose Adriano Baltieri Ping from XBase++
on Tue, 07 Dec 2010 11:31:30 -0200
Hello !

I'd like to build an application to monitor some sites and for doing that, the 
application needs to issue a PING.

May I do that from XBase++ itself ?

Of course I could RUNSHELL to PING but this is cumbersome.

Other ideas ?

Thanks !
Jorge LRe: Ping from XBase++
on Tue, 07 Dec 2010 14:12:50 -0300
Hi
pablo botella have a class to make a ping and a function that return the 
netbios name

"Jose Adriano Baltieri"  escribió en el mensaje de 
noticias:a379e68$60c834bf$d728@news.alaska-software.com...

Hello !

I'd like to build an application to monitor some sites and for doing that, 
the
application needs to issue a PING.

May I do that from XBase++ itself ?

Of course I could RUNSHELL to PING but this is cumbersome.

Other ideas ?

Thanks !
Steven SchefferRe: Ping from XBase++
on Thu, 30 Jun 2011 11:01:13 +0200
Use the WMI to peform the ping.

Regards,
Steven

FUNCTION wmiPingStatus( cIPAddress )
  LOCAL oWMiServices
  LOCAL oWmiInstances, aItem := {}, nItemPos
  LOCAL nStatusCode := -1
  LOCAL oWmiLocator := CreateObject( "WbemScripting.SWbemLocator" )

  DEFAULT cIPAddress TO "127.0.0.1"

  oWmiServices := oWmiLocator:ConnectServer( "Localhost", "Root\CIMv2" )
  oWMiServices := GetObject( "WinMgmts:\\localhost\Root\CIMV2" )
  IF VALTYPE( oWMiServices ) == "O"
    oWmiInstances := oWmiServices:ExecQuery( "Select * From Win32_PingStatus 
where Address = '"+cIPAddress+"'" )

    IF VALTYPE( oWmiInstances ) == "O"
      ComEvalCollection( oWmiInstances, { |oI| AADD( aItem , oI ) } )

      FOR nItemPos := 1 TO LEN( aItem )   deze is 1
        nStatusCode := aItem[nItemPos]:StatusCode
      NEXT

      IF VALTYPE( oWmiInstances ) == "O"
        oWmiInstances:destroy()        Disconnects from a COM component.
        oWmiInstances := NIL
      ENDIF
    ENDIF

    IF VALTYPE( oWMiServices ) == "O"
      oWMiServices:destroy()        Disconnects from a COM component.
      oWMiServices := NIL
    ENDIF
  ENDIF
  RETURN ( nStatusCode )
Altiy ZemlytskiyRe: Ping from XBase++
on Fri, 08 Jul 2011 16:26:23 +0300
FUNCTION SpPing(cIP)
LOCAL    lIPadr
LOCAL    lHopsCount := (0)
LOCAL    lMaxHops   := (20)
LOCAL    lRTT       := (0)

lIPadr := inet_addr(cIP)
IF GetRTTAndHopCount(lIPadr, @lHopsCount, lMaxHops, @lRTT ) = 1
    RETURN 1
ELSE
    RETURN GetLastError()
ENDIF
RETURN NIL

DLLFUNCTION GetLastError() ;
             USING STDCALL  ;
             FROM kernel32.dll

DLLFUNCTION GetRTTAndHopCount( lDestIPAddr, @lHopCount, lMaxHops, @lRTT) ;
             USING STDCALL ;
             FROM iphlpapi.dll

DLLFUNCTION inet_addr(cp) ;
             USING STDCALL ;
             FROM wsock32.dll