首页 > Linux操作系统 > Linux操作系统 > 发起GPRS拨号请求
using System;
using System.Collections.Generic;
using System.Text;
using OpenNETCF.Net;
using System.Windows.Forms;
using Microsoft.Win32;
namespace AnotherTodayScreenItem.Utl
{
///
/// 发起GPRS拨号请求
///
class ConnectNet
{
private OpenNETCF.Net.ConnectionManager ConnMgr = new OpenNETCF.Net.ConnectionManager();
private DestinationInfoCollection cenum;
private bool is_connected;
private static volatile ConnectNet m_instance = null;
public ConnectNet()
{
}
public static ConnectNet singleton
{
get
{
if (m_instance == null)
{
lock (typeof(ConnectNet))
{
if (m_instance == null)
{
m_instance = new ConnectNet();
}
}
}
return m_instance;
}
}
public void ConnGPRS(bool connect)
{
long startTime;
cenum = ConnMgr.EnumDestinations();
List
is_connected = false;
try
{
foreach (ConnectionDetail em in connectionDetail)
{
if (em.Description == "linkgprs")
{
if (connect)
{
RegMobile regManager = new RegMobile();
regManager.changeValue(RegMobile.HKEY.HKEY_LOCAL_MACHINE, em.Description);
ConnMgr.Connect(em.DestinatonNetwork, true, ConnectionMode.Asynchronous);
//mmmmmmmmmmmmmmmmmmmmmmmmConnMgr.Connect(em.DestinatonNetwork, true, ConnectionMode.Asynchronous);
startTime = DateTime.Now.Ticks;
while ((!is_connected) && (DateTime.Now.Ticks - startTime < 20 * TimeSpan.TicksPerSecond)) ;
break;
}
else
{
ConnMgr.RequestDisconnect();
}
}
}
}
catch (SystemException err)
{
MessageBox.Show(" err 700 " + err.Message);
}
}
public void close_connect()
{
ConnMgr.RequestDisconnect();
}
}
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/14766526/viewspace-561396/ ,如需转载,请注明出处,否则将追究法律责任。