홈 · 개발 참고자료

개발 참고자료

[파워빌더] Detect network and/or internet connectivity state (네트워크 또는 인터넷 연결 상태를 감지)

작성자
관리자
작성일
2016-10-16
조회
10153
분류
파워빌더
[Local function declaration]
FUNCTION boolean IsNetworkAlive(ref int flags) LIBRARY "sensapi.dll"


[Powerscript]
// The computer has one or more LAN cards that are active.
CONSTANT integer NETWORK_ALIVE_LAN = 1;
// The computer has one or more active RAS connections (internet).
CONSTANT integer NETWORK_ALIVE_WAN = 2;
// Win9x. The computer is connected to the America Online network.
CONSTANT integer NETWORK_ALIVE_AOL = 4;

OleObject wsh
int networkState, k

// to do the "bitwise AND" later...
wsh = CREATE OleObject
wsh.ConnectToNewObject( "MSScriptControl.ScriptControl" )
wsh.language = "vbscript"


IF IsNetworkAlive(networkState) THEN
// check if a network card is active
k = integer(wsh.Eval( string(networkState) + &
" AND " + &
string(NETWORK_ALIVE_LAN)))
IF k = NETWORK_ALIVE_LAN THEN
MessageBox("","network is ON")
ELSE
MessageBox("","network is OFF")
END IF

// check if internet connection is active
k = integer(wsh.Eval( string(networkState) + &
" AND " + &
string(NETWORK_ALIVE_WAN)))
IF k = NETWORK_ALIVE_WAN THEN
MessageBox("","internet is ON")
ELSE
MessageBox("","internet is OFF")
END IF
ELSE
MessageBox("","no network ?!?")
END IF
See this related HowTo