Gprs 可以通过什么方式来连接1.OpenNetCF中的System.Net类2.WindowsApi
unsafe public static uint myRasDial(string EntryName,string
UserName,string Password,out IntPtr RasConn) {
/*
EntryName ,UserName,Password - same as in RASDIALPARAMS structure (see
MSDN)
*/
uint r=0;
RasConn=IntPtr.Zero;
byte[] bRASDIALPARAMS =new byte[1464];
fixed (byte* pAddr = bRASDIALPARAMS) {
byte* pCurrent = pAddr;
Marshal.WriteInt32((IntPtr)pCurrent,bRASDIALPARAMS.Length);
pCurrent+=4;
foreach (byte b in Encoding.Unicode.GetBytes(EntryName)) {
Marshal.WriteByte((IntPtr)pCurrent, b);
pCurrent++;
}
pCurrent=pAddr+0x192;//0x192 - offset for RASDIALPARAMS.UserName
foreach (byte b in Encoding.Unicode.GetBytes(UserName)) {
Marshal.WriteByte((IntPtr)pCurrent, b);
pCurrent++;
}
pCurrent=pAddr+0x394;//0x394 - offset for RASDIALPARAMS.Password
foreach (byte b in Encoding.Unicode.GetBytes(Password)) {
Marshal.WriteByte((IntPtr)pCurrent, b);
pCurrent++;
}
r=RasDial(IntPtr.Zero,IntPtr.Zero,(IntPtr)pAddr,0,IntPtr.Zero,ref
RasConn);
}
return r;
}
[DllImport("coredll.dll")]
public static extern uint RasDial(IntPtr dialExtensions,IntPtr
phoneBookPath,IntPtr rasDialParam,uint NotifierType,
IntPtr notifier, ref IntPtr pRasConn);
[DllImport("coredll.dll")]
public static extern uint RasHangUp(IntPtr pRasConn);
//------------------------------------------------------------------------
Example of using myRasDial
IntPtr rc; // connection handle
if(myRasDial("BeelineGPRS","beeline","beeline",out rc)==0) { //success
try {
TcpClient client = new TcpClient("www.someaddress.com", someport);
MessageBox.Show("OK");
//..................................
}
catch(Exception ex) {
MessageBox.Show(ex.Message);
}
RasHangUp(rc);
}3.HttpWebRequest
4.不知道了。
unsafe public static uint myRasDial(string EntryName,string
UserName,string Password,out IntPtr RasConn) {
/*
EntryName ,UserName,Password - same as in RASDIALPARAMS structure (see
MSDN)
*/
uint r=0;
RasConn=IntPtr.Zero;
byte[] bRASDIALPARAMS =new byte[1464];
fixed (byte* pAddr = bRASDIALPARAMS) {
byte* pCurrent = pAddr;
Marshal.WriteInt32((IntPtr)pCurrent,bRASDIALPARAMS.Length);
pCurrent+=4;
foreach (byte b in Encoding.Unicode.GetBytes(EntryName)) {
Marshal.WriteByte((IntPtr)pCurrent, b);
pCurrent++;
}
pCurrent=pAddr+0x192;//0x192 - offset for RASDIALPARAMS.UserName
foreach (byte b in Encoding.Unicode.GetBytes(UserName)) {
Marshal.WriteByte((IntPtr)pCurrent, b);
pCurrent++;
}
pCurrent=pAddr+0x394;//0x394 - offset for RASDIALPARAMS.Password
foreach (byte b in Encoding.Unicode.GetBytes(Password)) {
Marshal.WriteByte((IntPtr)pCurrent, b);
pCurrent++;
}
r=RasDial(IntPtr.Zero,IntPtr.Zero,(IntPtr)pAddr,0,IntPtr.Zero,ref
RasConn);
}
return r;
}
[DllImport("coredll.dll")]
public static extern uint RasDial(IntPtr dialExtensions,IntPtr
phoneBookPath,IntPtr rasDialParam,uint NotifierType,
IntPtr notifier, ref IntPtr pRasConn);
[DllImport("coredll.dll")]
public static extern uint RasHangUp(IntPtr pRasConn);
//------------------------------------------------------------------------
Example of using myRasDial
IntPtr rc; // connection handle
if(myRasDial("BeelineGPRS","beeline","beeline",out rc)==0) { //success
try {
TcpClient client = new TcpClient("www.someaddress.com", someport);
MessageBox.Show("OK");
//..................................
}
catch(Exception ex) {
MessageBox.Show(ex.Message);
}
RasHangUp(rc);
}3.HttpWebRequest
4.不知道了。
解决方案 »
- 怎么样进行有效验证?
- socket 通信,高手帮帮忙那,困扰了好几天了崩溃了
- winfrom中关于中文转化为encodeUri
- 日程提醒会弹出8个窗口,那位高手能解答是什么原因呀?
- C# windows应用程序带SQl数据库的问题
- rar的命令行能不能修改密码??咋整。
- c#调用delphi dll出现的问题
- windows service如何打包,并安装在客户端????
- 在制作登陆页面的时候总是不能成功登陆,以下是我的代码,用vs2005和sql2000
- 公司问我们需要订什么技术资料,请各位帮推荐几本好的!!谢谢!!
- Backgroundworker循環复制大文件
- 怎么样转换生成的文本文件的编码格式
internal unsafe static extern int ConnMgrEstablishConnection(CONNMGR_CONNECTIONINFO pConnInfo, out IntPtr hConnection); [DllImport("cellcore.dll", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention = CallingConvention.Winapi)]
internal unsafe static extern int ConnMgrReleaseConnection(IntPtr hConnection, int bCache); [DllImport("cellcore.dll", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention = CallingConvention.Winapi)]
internal unsafe static extern int ConnMgrMapURL(string url, ref Guid guid, int* nIndex); [DllImport("cellcore.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal unsafe static extern int ConnMgrEstablishConnectionSync(CONNMGR_CONNECTIONINFO pConnInfo, out IntPtr hConn, uint timeout, ref uint status); [DllImport("cellcore.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal unsafe static extern int ConnMgrConnectionStatus(IntPtr hConnection, uint* status);wince的代码