|
本帖最后由 mdyblog 于 2022-8-2 22:23 编辑
函数
IsConnectInternet // BICon [bLCon]
目前用的简化写法,需要 {28o版} PECMD。
{28o版}\示例\IsConnectInternet.wcs 含文档
MSDN文档传到网盘了,方便找调用API需要的资料
=======================================
ENVI^ ForceLocal=1
IsConnectInternet &&InternetRet &&LocalRet
MESS Internet[%&InternetRet%] LocalNet[%LocalRet%]
_SUB IsConnectInternet // BICon [bLCon]
SET &bIntnet=
SET &bLConnect=
SET$ &mpNetworkListManager=*8 0
SET &CLSCTX_INPROC_SERVER=0x1
CALC #&&CLSCTX_ALL=1|2|4|0x10
SET#$ &CLSID_NetworkListManager=01 0C B0 DC 0F 57 9B 4A 8D 69 19 9F DB A5 72 3B //{DCB00C01-570F-4A9B-8D69-199FDBA5723B}
SET#$ &IID_INetworkListManager=00 00 B0 DC 0F 57 9B 4A 8D 69 19 9F DB A5 72 3B //{DCB00000-570F-4A9B-8D69-199FDBA5723B}
SET &pNetworkListManager=0
{*
lock .ole
CALL $--ret:* --qd --16 OLE32.DLL,CoCreateInstance,&&rs,*CLSID_NetworkListManager,#0,#%CLSCTX_ALL%,*IID_INetworkListManager,*mpNetworkListManager
IFEX #[ 0<>%&rs% ], EXIT -
SET &get_IsConnectedToInternet=11 //函数序号
SET &get_IsConnected=12 //函数序号
SET#$ &IsConnect=*8 0
FIND $%~1<>,
{* ^CALL $--ret:&&rs --qd* #,*&mpNetworkListManager.%get_IsConnectedToInternet%,IsConnect
@IFEX #%rs%=0,!! @IFEX #%&IsConnect?short:0%<>0, SET bIntnet=1! SET SET bIntnet=0
}
FIND $%~2<>,
{* CALL $--ret:&&rs --qd* #,*&mpNetworkListManager.%get_IsConnected%,IsConnect
@IFEX #%rs%=0,!! @IFEX #%&IsConnect?short:0%<>0, SET bIntnet=1! SET SET bIntnet=0
}
CALL $--ret:&&rs #,*&mpNetworkListManager.2 //2:Release() 释放COM
}
ENVI-ret %~1=%bIntnet%
FIND $%~2<>, ENVI-ret %~2=%bLConnect%
_END
|
|