gprs 自动拨号 wince ppc
来源:互联网 发布:mac pro 2016 尺寸 编辑:程序博客网 时间:2024/05/21 11:22
因为当我们做一个http请求时ppc会自动拨号,但是如果我们使用UDP做数据传输时是不会自动拨号的,为此我曾经给windowmobile@microsoft.com发邮件询问怎样用C#实现GPRS拨号.MS告诉我可以先做一个HTTP请求.做为一个应急的方案确实可以这样做.
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Net;
- using System.Runtime.InteropServices;
- using System.Threading;
- using System.Collections;
- namespace PPc.GPRS
- {
- public class GPRSConnection
- {
- const int S_OK = 0;
- const uint CONNMGR_PARAM_GUIDDESTNET = 0x1;
- const uint CONNMGR_FLAG_PROXY_HTTP = 0x1;
- const uint CONNMGR_PRIORITY_USERINTERACTIVE = 0x08000;
- const uint INFINITE = 0xffffffff;
- const uint CONNMGR_STATUS_CONNECTED = 0x10;
- static Hashtable ht = new Hashtable();
- static GPRSConnection()
- {
- ManualResetEvent mre = new ManualResetEvent(false);
- mre.Handle = ConnMgrApiReadyEvent();
- mre.WaitOne();
- CloseHandle(mre.Handle);
- }
- ~GPRSConnection()
- {
- ReleaseAll();
- }
- public static bool Setup(Uri url)
- {
- return Setup(url.ToString());
- }
- public static bool Setup(string urlStr)
- {
- ConnectionInfo ci = new ConnectionInfo();
- IntPtr phConnection = IntPtr.Zero;
- uint status = 0;
- if (ht[urlStr] != null)
- {
- return true;
- }
- if (ConnMgrMapURL(urlStr, ref ci.guidDestNet, IntPtr.Zero) != S_OK)
- {
- return false;
- }
- ci.cbSize = (uint)Marshal.SizeOf(ci);
- ci.dwParams = CONNMGR_PARAM_GUIDDESTNET;
- ci.dwFlags = CONNMGR_FLAG_PROXY_HTTP;
- ci.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
- ci.bExclusive = 0;
- ci.bDisabled = 0;
- ci.hWnd = IntPtr.Zero;
- ci.uMsg = 0;
- ci.lParam = 0;
- if (ConnMgrEstablishConnectionSync(ref ci, ref phConnection, INFINITE, ref status) != S_OK && status != CONNMGR_STATUS_CONNECTED)
- {
- return false;
- }
- ht[urlStr] = phConnection;
- return true;
- }
- public static bool Release(Uri url)
- {
- return Release(url.ToString());
- }
- public static bool Release(string urlStr)
- {
- return Release(urlStr, true);
- }
- private static bool Release(string urlStr, bool removeNode)
- {
- bool res = true;
- IntPtr ph = IntPtr.Zero;
- if (ht[urlStr] == null)
- {
- return true;
- }
- ph = (IntPtr)ht[urlStr];
- if (ConnMgrReleaseConnection(ph, 1) != S_OK)
- {
- res = false;
- }
- CloseHandle(ph);
- if (removeNode)
- {
- ht.Remove(urlStr);
- }
- return res;
- }
- public static void ReleaseAll()
- {
- foreach (DictionaryEntry de in ht)
- {
- Release((string)de.Key, false);
- }
- ht.Clear();
- }
- [StructLayout(LayoutKind.Sequential)]
- public struct ConnectionInfo
- {
- public uint cbSize;
- public uint dwParams;
- public uint dwFlags;
- public uint dwPriority;
- public int bExclusive;
- public int bDisabled;
- public Guid guidDestNet;
- public IntPtr hWnd;
- public uint uMsg;
- public uint lParam;
- public uint ulMaxCost;
- public uint ulMinRcvBw;
- public uint ulMaxConnLatency;
- }
- [DllImport("cellcore.dll")]
- private static extern int ConnMgrMapURL(string pwszURL, ref Guid pguid, IntPtr pdwIndex);
- [DllImport("cellcore.dll")]
- private static extern int ConnMgrEstablishConnectionSync(ref ConnectionInfo ci, ref IntPtr phConnection, uint dwTimeout, ref uint pdwStatus);
- [DllImport("cellcore.dll")] private static extern IntPtr ConnMgrApiReadyEvent();
- [DllImport("cellcore.dll")] private static extern int ConnMgrReleaseConnection(IntPtr hConnection, int bCache);
- [DllImport("coredll.dll")] private static extern int CloseHandle(IntPtr hObject);
- }
- }
- e.g :
- GPRSConnection .Setup("http://www.microsoft.com");
- gprs 自动拨号 wince ppc
- gprs 自动拨号 wince ppc
- WinCE下GPRS拨号
- PPC自动拨号
- 自动连接GPRS拨号
- mobile和wince下的gprs拨号
- wince下实现GPRS上网,程序控制拨号
- wince下实现GPRS上网,程序控制拨号 .
- WinCE下GPRS拨号连接助手
- WinCE使用Unimodem进行GPRS拨号总结(By wwfiney@ARMCE)
- WINCE下的GPRS拨号连接(一)
- WINCE下的GPRS拨号连接(二)
- c# wince 禁止gprs/wcdma拨号时候弹出密码输入框
- gprs ppp拨号
- GPRS实现pppd拨号
- GPRS MODEM拨号错误代码
- 3G模块在wince下的自动拨号
- linux ppp GPRS拨号问题
- DM6467 之视频采集(linux)下mmap
- 你目前使用的LoadRunner版本调查
- struts2的Action传参总结
- dedecms获得某篇文章内容的几种方法
- 网站中痕迹保留的实现
- gprs 自动拨号 wince ppc
- 多线程问题cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *
- java Socket编程(二)
- overload和override的区别
- 可通过 @font-face 使用
- C++ 第十三周报告1
- 设计模式学习
- Python操作Word、EXCEL,ACCESS
- C++ 第十三周报告2