by ADutheil » Sun Nov 14, 2010 2:11 pm
The function below works with open VPN client. If you use another way to connect to your VPN you might adapt it to fit your needs. The only thing you have to know is the IP address of the VPN. In my case DHCP server returns an IP from the 172.20.20.0/24 net. So I set the cWlan param to "172.20.20.".
FUNCTION ChkVPN
LOCAL nHips := fCreate( "listip.bat" )
LOCAL cBuff := ""
LOCAL lRetu := .F.
LOCAL cWlan := "172.20.20."
fWrite( nHips, "ipconfig >listip.lst" )
fClose( nHips )
ShellExecute( 0, "open", "listip.bat",,, )
IF ( nHips := fOpen( "listip.lst" ) ) > 0
WHILE hb_fReadLine( nHips, @cBuff ) = 0
IF cWlan $ cBuff
lRetu := .T.
EXIT
ENDIF
ENDDO
fClose( nHips )
ELSE
msgStop( "UNABLE TO OPEN FILE listip.LST" )
ENDIF
fErase( "listip.bat" )
fErase( "listip.lst" )
IF !lRetu
msgStop( "VPN NOT CONNECTED!" )
ENDIF
RETURN ( lRetu )
To launch your VPN you can use winexec() function
Regards,
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10