Office中国论坛/Access中国论坛
标题:
[转帖]如何检测本人网卡已经物理连接到了网络上?
[打印本页]
作者:
adepda
时间:
2006-11-19 16:07
标题:
[转帖]如何检测本人网卡已经物理连接到了网络上?
WinInet.DLL的InternetGetConnectedState(&dwFlag,0)函数:
注意:为使用该函数,须在项目文件中加入:USELIB("WinInet.LIB")
特点:获得较详的连接描述!
-----------WinInet.DLL的InternetGetConnectedState函数法----------------
StaticText1->Caption=""; StaticText2->Caption=""; StaticText3->Caption="";
StaticText4->Caption=""; StaticText5->Caption=""; StaticText6->Caption="";
StaticText7->Caption="";
DWORD dwFlag;
InternetGetConnectedState(&dwFlag,0);
if(dwFlag & INTERNET_CONNECTION_MODEM) StaticText1->Caption="Yes"; MODEM连接
else StaticText1->Caption="No";
if(dwFlag & INTERNET_CONNECTION_LAN) StaticText2->Caption="Yes"; LAN连接
else StaticText2->Caption="No";
if(dwFlag & INTERNET_CONNECTION_PROXY) StaticText3->Caption="Yes"; 代理连接
else StaticText3->Caption="No";
---------检查是否连接-------------------------------------------
if(InternetGetConnectedState(NULL,0)) StaticText4->Caption="Yes"; 在线
else StaticText4->Caption="No";
if(dwFlag & INTERNET_CONNECTION_OFFLINE) StaticText5->Caption="Yes";//离线。注:不好用!
else StaticText5->Caption="No";
----------------------------------------------------------------
if(dwFlag & INTERNET_RAS_INSTALLED) StaticText6->Caption="Yes";
else StaticText6->Caption="No";
if(dwFlag & INTERNET_CONNECTION_CONFIGURED) StaticText7->Caption="Yes";
else StaticText7->Caption="No";
*/
DWORD dwFlags=0;
if(InternetGetConnectedState(&dwFlags,0)) //使用这个函数必须在工程里添加:USELIB("WinInet.LIB");
Application->MessageBoxA("网络正常连接!","提示信息",0 );
else
Application->MessageBoxA("机器不在网络上!","提示信息",0 );
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3