应用程序如何检测本计算机是否有连接网线???

mdejtod 2006-06-12 08:39:40
如题~~~我的一个程序中是有用到搜索局域网中所有计算机的SQL数据库的,如果计算机上有连接网线,则可以实现该功能,但是如果没有网线时,不起作用了,要如何进行判断?
...全文
416 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
mdejtod 2006-06-12
  • 打赏
  • 举报
回复
晕哦~~~现在不都可以上网的~~~~可
dwconnectiontypes:=INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN +
INTERNET_CONNECTION_PROXY;
它的值起先为17,(没有插网线)
我插网线后一直为18,结果是为假的啊.
试试 postren(小虫) 的方法看~
天涯倦客 2006-06-12
  • 打赏
  • 举报
回复
确定你要连接的网络
ping 下交换机。。 或者其他 ip
postren 2006-06-12
  • 打赏
  • 举报
回复
放到一个timer中,每隔几秒检测一下网络状态

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if InternetConnected then
Caption := '网络正常'
else
Caption := '无网络';
end;
mdejtod 2006-06-12
  • 打赏
  • 举报
回复
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;
可不知道为什么第一次把网线拨掉时会运行正常,提示无网络状态,可将网线插上后还一直提示'无网络状态~!!
mdejtod 2006-06-12
  • 打赏
  • 举报
回复
我试过了~~检测不出来~~这样达不到效果,我要的是判断计算机有没有连接到网络中,不管采用哪种连接方式.相当于判断有没有插网线的意思~~~
postren 2006-06-12
  • 打赏
  • 举报
回复
DWORD 是32位的一个整型值,楼上的代码需要uses Wininet

//检查连网状态
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;
mdejtod 2006-06-12
  • 打赏
  • 举报
回复
伤心~啊~咋这么冷清~~
mdejtod 2006-06-12
  • 打赏
  • 举报
回复
看得不太明白~~~dword 这个是什么类型的呢?
nternet_connection_lan 这个又表示什么意思??
不好意思哦~~~我是新手~加菜鸟~!
lxzhong 2006-06-12
  • 打赏
  • 举报
回复
//检查连网状态
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;
mdejtod 2006-06-12
  • 打赏
  • 举报
回复
没得救了~~~各位帮帮忙啊!~!还是不行期 dwconnectiontypes 值有问题!
还有问下有哪位有用过sqldmo_tlb这个文件???????
要修改application类,可不懂在哪里修改,现在程序中一直不能用application.方法,与DELPHI自定义的application类有冲突!

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧