var dwConnectState:integer; bok:boolean; begin bOK := InternetGetConnectedState( @dwConnectState, 0); dwConnectState := INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN + INTERNET_CONNECTION_PROXY +INTERNET_CONNECTION_MODEM_BUSY ; if ( bOK ) then begin if (dwConnectState and INTERNET_CONNECTION_LAN)=1 then strConnectState := 'Local system uses a local area network to connect to the Internet. '; if ( dwConnectState and INTERNET_CONNECTION_MODEM )=1 then strConnectState := 'Local system uses a modem to connect to the Internet. '; if ( dwConnectState and INTERNET_CONNECTION_MODEM_BUSY )=1 then strConnectState := 'No longer used. '; if ( dwConnectState and INTERNET_CONNECTION_PROXY )=1 then strConnectState := 'Local system uses a proxy server to connect to the Internet. '; end else strConnectState := 'No!';
拔了网线也检测不出来,看来只有ping了
procedure TForm1.Button1Click(Sender: TObject); var dwConnectState:integer; bok:boolean; strConnectState:string; pstr:PChar; begin dwConnectState:=INTERNET_CONNECTION_PROXY; bOK := InternetGetConnectedState(@dwConnectState, 0); if ( bOK ) then label1.Caption:='Local system uses a proxy server to connect to the Internet. '; dwConnectState:=INTERNET_CONNECTION_LAN; bOK := InternetGetConnectedState(@dwConnectState, 0); if ( bOK ) then label1.Caption:='Local system uses a local area network to connect to the Internet. '; end;
没有呀,我的机器现在就是通过代理上网的。可以返回 'Local system uses a proxy server to connect to the Internet. '
抱歉,的确是返回:'Local system uses a local area network to connect to the Internet. ' 柄没有返回 'Local system uses a proxy server to connect to the Internet
回复贴子: 回复人: unique(伪程序员) (2001-2-15 14:45:00) 得20分 用系统的url.dll(这个dll,系统一般都有ie5,office都包含这个dll)function InetIsOffline(Flag: Integer): Boolean; stdcall; external 'URL.DLL';调用代码: procedure TFrmInternetDemo.Button1Click(Sender: TObject); begin if InetIsOffline(0) then ShowMessage('This computer is not connected to Internet!') else ShowMessage('You are connected to Internet!'); end;
dwConnectState:integer;
bok:boolean;
begin
bOK := InternetGetConnectedState( @dwConnectState, 0);
dwConnectState := INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN + INTERNET_CONNECTION_PROXY +INTERNET_CONNECTION_MODEM_BUSY ;
if ( bOK ) then
begin
if (dwConnectState and INTERNET_CONNECTION_LAN)=1 then
strConnectState := 'Local system uses a local area network to connect to the Internet. ';
if ( dwConnectState and INTERNET_CONNECTION_MODEM )=1 then
strConnectState := 'Local system uses a modem to connect to the Internet. ';
if ( dwConnectState and INTERNET_CONNECTION_MODEM_BUSY )=1 then
strConnectState := 'No longer used. ';
if ( dwConnectState and INTERNET_CONNECTION_PROXY )=1 then
strConnectState := 'Local system uses a proxy server to connect to the Internet. ';
end
else
strConnectState := 'No!';
var
dwConnectState:integer;
bok:boolean;
strConnectState:string;
pstr:PChar;
begin
dwConnectState:=INTERNET_CONNECTION_PROXY; bOK := InternetGetConnectedState(@dwConnectState, 0);
if ( bOK ) then
label1.Caption:='Local system uses a proxy server to connect to the Internet. '; dwConnectState:=INTERNET_CONNECTION_LAN;
bOK := InternetGetConnectedState(@dwConnectState, 0);
if ( bOK ) then
label1.Caption:='Local system uses a local area network to connect to the Internet. ';
end;
柄没有返回 'Local system uses a proxy server to connect to the Internet
回复贴子:
回复人: unique(伪程序员) (2001-2-15 14:45:00) 得20分
用系统的url.dll(这个dll,系统一般都有ie5,office都包含这个dll)function InetIsOffline(Flag: Integer): Boolean; stdcall; external 'URL.DLL';调用代码:
procedure TFrmInternetDemo.Button1Click(Sender: TObject);
begin
if InetIsOffline(0) then
ShowMessage('This computer is not connected to Internet!')
else
ShowMessage('You are connected to Internet!');
end;