function TE_databasef.InternetConnected: boolean;
var
dwconnectiontypes : integer;
begin
dwconnectiontypes:=INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN +
INTERNET_CONNECTION_PROXY;
if InternetGetConnectedState(@dwconnectiontypes, 0) then
Result := False
else
Result := True;
end;
在该窗体创建时进行判断 if not InternetConnected then
showmessage('无网络状态')
else
begin
end;
可不知道为什么第一次把网线拨掉时会运行正常,提示无网络状态,可将网线插上后还一直提示'无网络状态~!!
//检查连网状态
function TForm1.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_lan;
result := internetgetconnectedstate(@dwconnectiontypes, 0);
end;
//检查连网状态
function TForm1.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 := nternet_connection_lan;
result := internetgetconnectedstate(@dwconnectiontypes, 0);
end;