黎波

Windows Mobile Development for Line of Business
posts - 187, comments - 1266, trackbacks - 43, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

检测本地计算机是否连上Internet

Posted on 2005-04-20 04:56 黎波 阅读(881) 评论(2)  编辑 收藏 所属分类: Smart Client

[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int connectionDescription, int reservedValue ) ;

/// <summary>
/// Retrieves the connected state of the local system.
/// </summary>
/// <returns>Returns True if there is an Internet connection, or False otherwise.</returns>
public bool IsConnected()
{
    
int connectionDescription = 0;
    
return InternetGetConnectedState(out connectionDescription, 0);
}

References:
Microsoft Offline Application Block
WinINetDetectionStrategy.cs

Feedback

#1楼    回复  引用  查看    

2007-10-03 21:43 by wangshangy      
您好,这段代码,在PC上,使用很正常,但我在Windows Mobile上(设备和模拟器情况一样)上使用的时候,不管连接与否,返回值都是一样的,都是true。我查了一下,在SDK上面是有这个库和函数的啊?不知道为什么不能正常使用?

#2楼 [楼主]   回复  引用  查看    

2007-10-22 23:15 by 黎波      
@wangshangy
这段代码是用于PC的。关于如何检测Mobile设备的Connection状态,可以参考 Mobile Client Software Factory - July 2006 中的 Connection Monitor。

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2005-05-24 23:42 编辑过
"五向定位"职业成长路线公开课(上海、南京、大连)
Google站内搜索


相关链接: