Windows Mobile 开发的一些小技巧
2010-02-26 16:10:00 来源:WEB开发网核心提示:";7.发起和断开连接这两个方法需要另外两个类的协助public static void MakeConnection(){try{ConnectionManager connectManager = new ConnectionManager();int idx = -1;List lstIdentifie
";
7.发起和断开连接
这两个方法需要另外两个类的协助
public static void MakeConnection()
{
try
{
ConnectionManager connectManager = new ConnectionManager();
int idx = -1;
List
for (int i = 0; i < lstIdentifiers.Count; i++)
{
if ("Internet 连接".Equals(lstIdentifiers[i].Description))
{
idx = i;
break;
}
}
if (idx > -1)
{
connectManager.EstablishConnection((uint)idx);
}
}
catch
{
}
}
public static void Disconnect()
{
try
{
RASManager.RASCONN[] conns = RASManager.GetRASConnections();
if (conns != null && conns.Length > 0)
{
foreach (RASManager.RASCONN conn in conns)
{
try
{
RASManager.HangUp(conn.hRasConnHandle);
}
catch (Exception ex)
{
}
}
}
}
catch
{
}
}
更多精彩
赞助商链接