程序启动后判断是否上网,如果电脑未连接到网络,那么所有的panel 都显示,如果电脑已连接网络,那就所有的panel 都隐藏!求高手帮忙!现在有网络收集相关代码:=================================================================
功 能: 检测计算机是否上网
参 数: 无
返回值: 成功: True 失败: False;
备 注: uses Wininet
版 本: 1.0 2003/08/11
=================================================================}
function InternetConnected: Boolean;
const
// local system uses a modem to connect to the Internet.
INTERNET_CONNECTION_MODEM = 1;
// local system uses a local area network to connect to the Internet.
INTERNET_CONNECTION_LAN = 2;
// local system uses a proxy server to connect to the Internet.
INTERNET_CONNECTION_PROXY = 4;
// local system's modem is busy with a non-Internet connection.
INTERNET_CONNECTION_MODEM_BUSY = 8;
var
dwConnectionTypes : DWORD;
begin
dwConnectionTypes := INTERNET_CONNECTION_MODEM+ INTERNET_CONNECTION_LAN
+ INTERNET_CONNECTION_PROXY;
Result := InternetGetConnectedState(@dwConnectionTypes, 0);
end;
功 能: 检测计算机是否上网
参 数: 无
返回值: 成功: True 失败: False;
备 注: uses Wininet
版 本: 1.0 2003/08/11
=================================================================}
function InternetConnected: Boolean;
const
// local system uses a modem to connect to the Internet.
INTERNET_CONNECTION_MODEM = 1;
// local system uses a local area network to connect to the Internet.
INTERNET_CONNECTION_LAN = 2;
// local system uses a proxy server to connect to the Internet.
INTERNET_CONNECTION_PROXY = 4;
// local system's modem is busy with a non-Internet connection.
INTERNET_CONNECTION_MODEM_BUSY = 8;
var
dwConnectionTypes : DWORD;
begin
dwConnectionTypes := INTERNET_CONNECTION_MODEM+ INTERNET_CONNECTION_LAN
+ INTERNET_CONNECTION_PROXY;
Result := InternetGetConnectedState(@dwConnectionTypes, 0);
end;
var
Icmp : TIdIcmpClient; // D7 提供的组件
begin
Screen.Cursor := crHourGlass;
Result := False;
Icmp := TIdIcmpClient.Create(Application);
try
try
Icmp.Host := Trim(IP);
Icmp.ReceiveTimeout := 5000;
Icmp.Ping();
if Icmp.ReplyStatus.BytesReceived >0 then Result := True
except
Application.MessageBox('网络接口故障, 请先尝试如下方式: ' + #13#10#10 + '先登录到本机, 退出后再登录网络','Sraft 提示')
end;
finally
Icmp.Free;
end;
Screen.Cursor := crDefault;
end;