|
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 );
|
|