delphi如何判断网络是否连接
答案:2 悬赏:40 手机版
解决时间 2021-04-02 03:49
- 提问者网友:世勋超人
- 2021-04-01 06:16
delphi如何判断网络是否连接
最佳答案
- 五星知识达人网友:低音帝王
- 2021-04-01 07:27
uses添加wininet;
procedure TForm1.Button1Click(Sender: TObject);
var
Types:integer;
begin
Types:=INTERNET_CONNECTION_MODEM+INTERNET_CONNECTION_LAN+INTERNET_CONNECTION_PROXY;
if internetGetConnectedState(@types,0) then
edit1.text:='已经连接'
else
edit1.text:='没有连接';
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Types:integer;
begin
Types:=INTERNET_CONNECTION_MODEM+INTERNET_CONNECTION_LAN+INTERNET_CONNECTION_PROXY;
if internetGetConnectedState(@types,0) then
edit1.text:='已经连接'
else
edit1.text:='没有连接';
end;
全部回答
- 1楼网友:duile
- 2021-04-01 08:34
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Sockets;
type
TForm1 = class(TForm)
TcpServer1: TTcpServer;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
try
TcpServer1.Active :=True ;
ShowMessage('网络已连接')
except
ShowMessage('网络没连接');
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Sockets;
type
TForm1 = class(TForm)
TcpServer1: TTcpServer;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
try
TcpServer1.Active :=True ;
ShowMessage('网络已连接')
except
ShowMessage('网络没连接');
end;
end;
end.
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯