by ADutheil » Thu Nov 04, 2010 9:43 pm
Is the function below OK for you?
FUNCTION ChkIp( cMac )
LOCAL nMacs := fCreate( "macs.bat" )
LOCAL cBuff := ""
LOCAL lRetu := .F.
fWrite( nMacs, "arp -a >macs.lst" )
fClose( nMacs )
ShellExecute( 0, "open", "macs.bat",,, )
IF ( nMacs := fOpen( "macs.lst" ) ) > 0
WHILE hb_fReadLine( nMacs, @cBuff ) = 0
IF upper( cMac ) $ upper( cBuff )
msgInfo( "IP FOUND" + CRLF + allTrim( subStr( cBuff, 1, at( cMac, cBuff ) - 1 ) ) )
lRetu := .T.
EXIT
ENDIF
ENDDO
fClose( nMacs )
ELSE
msgStop( "UNABLE TO OPEN FILE MACS.LST" )
ENDIF
fErase( "macs.bat" )
fErase( "macs.lst" )
IF !lRetu
msgStop( "MAC " + cMac + CRLF + "IP NOT FOUND!" )
ENDIF
RETURN ( lRetu )
The cMac param must be sent as xx-xx-xx-xx-xx-xx
Regards,
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10