- [남군]빛고을총각
- 0
- 54
- 0
- 0
- 2019-08-05 14:52:01
- 관련링크
- 제목 : 인터넷 연결여부
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, WinInet, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
INTERNET_RAS_INSTALLED = $10;
INTERNET_CONNECTION_OFFLINE = $20;
INTERNET_CONNECTION_CONFIGURED = $30;
implementation
{$R *.dfm}
function internetConnected : boolean;
var
dwConnectionTypes : DWORD;
begin
if(InternetGetConnectedState(@dwConnectionTypes, 0)) then
begin
if((dwConnectionTypes and INTERNET_CONNECTION_MODEM) <> 0)then Result := True;
if((dwConnectionTypes and INTERNET_CONNECTION_LAN) <> 0)then Result := True;
if((dwConnectionTypes and INTERNET_CONNECTION_PROXY) <> 0)then Result := True;
if((dwConnectionTypes and INTERNET_CONNECTION_MODEM_BUSY) <> 0)then Result := True;
if((dwConnectionTypes and INTERNET_RAS_INSTALLED) <> 0)then Result := True;
if((dwConnectionTypes and INTERNET_CONNECTION_OFFLINE) <> 0)then Result := True;
if((dwConnectionTypes and INTERNET_CONNECTION_CONFIGURED) <> 0)then Result := True;
end
else
begin
Result := False;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if internetConnected then
showmessage('connected')
else
showmessage('disconnected');
end;
end.
- 첨부파일
- 댓글