我有一台运行 Windows Mobile 5.0 的设备。它有一个程序,可以在运行时即时创建和删除手持设备的 GPRS 连接。
我正在尝试构建一个可以做类似事情的小程序。可以通过参数调用它来启动连接,但是连接需要保持,以便之后即使我的程序没有运行也可以使用手机。
使用这篇 MSDN 文章,我编写了一些代码,可以很好地创建 GPRS 连接(连接成功)但是,它似乎不是手机可以使用的连接。
在我的程序运行后,我有什么方法可以使设备连接可用?如果是这样,那是特定于设备的吗?
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | [DllImport("CellCore.dll")] static extern int ConnMgrMapURL(string url, ref Guid networkGuid, int passZero); [DllImport("CellCore.dll")] static extern int ConnMgrEstablishConnection(ConnMgrConnectionInfo connectionInfo, ref IntPtr connectionHandle); [DllImport("CellCore.dll")] static extern int ConnMgrEstablishConnectionSync(ConnMgrConnectionInfo connectionInfo, ref IntPtr connectionHandle, uint dwTimeout, ref ConnMgrStatus dwStatus); [DllImport("CellCore.dll")] static extern int ConnMgrReleaseConnection(IntPtr connectionHandle, int cache); [DllImport("CellCore.dll")] static extern int ConnMgrConnectionStatus(IntPtr connectionHandle, ref ConnMgrStatus status); public void Start(string name) { string url ="http://internet.com/"; IntPtr _connectionHandle = IntPtr.Zero; Guid networkGuid = Guid.Empty; ConnMgrStatus status = ConnMgrStatus.Unknown; ConnMgrMapURL(url, ref networkGuid, 0); ConnMgrConnectionInfo info = new ConnMgrConnectionInfo(networkGuid, ConnMgrPriority.HighPriorityBackground); ConnMgrEstablishConnectionSync(info, ref _connectionHandle, _syncConnectTimeOut, ref status); if (status == ConnMgrStatus.Connected) { Debug.WriteLine("Connect Succeeded"); } else { Debug.WriteLine("Connect failed:" + status.ToString()); } } [Flags] enum ConnMgrParam : int { GuidDestNet = 0x1, MaxCost = 0x2, MinRcvBw = 0x4, MaxConnLatency = 0x8 } [Flags] enum ConnMgrProxy : int { NoProxy = 0x0, Http = 0x1, Wap = 0x2, Socks4 = 0x4, Socks5 = 0x8 } enum ConnMgrPriority { UserInteractive = 0x8000, HighPriorityBackground = 0x0200, LowPriorityBackground = 0x0008 } enum ConnMgrStatus { Unknown = 0x00, Connected = 0x10, Suspended = 0x11, Disconnected = 0x20, ConnectionFailed = 0x21, ConnectionCanceled = 0x22, ConnectionDisabled = 0x23, NoPathToDestination = 0x24, WaitingForPath = 0x25, WaitingForPhone = 0x26, PhoneOff = 0x27, ExclusiveConflict = 0x28, NoResources = 0x29, ConnectionLinkFailed = 0x2a, AuthenticationFailed = 0x2b, NoPathWithProperty = 0x2c, WaitingConnection = 0x40, WaitingForResource = 0x41, WaitingForNetwork = 0x42, WaitingDisconnection = 0x80, WaitingConnectionAbort = 0x81 } [StructLayout(LayoutKind.Sequential)] class ConnMgrConnectionInfo { Int32 cbSize; // DWORD public ConnMgrParam dwParams = 0; // DWORD public ConnMgrProxy dwFlags = 0; // DWORD public ConnMgrPriority dwPriority = 0; // DWORD public Int32 bExclusive = 0; // BOOL public Int32 bDisabled = 0; // BOOL public Guid guidDestNet = Guid.Empty; // GUID public IntPtr hWnd = IntPtr.Zero; // HWND public UInt32 uMsg = 0; // UINT public Int32 lParam = 0; // LPARAM public UInt32 ulMaxCost = 0; // ULONG public UInt32 ulMinRcvBw = 0; // ULONG public UInt32 ulMaxConnLatency = 0; // ULONG public ConnMgrConnectionInfo() { cbSize = Marshal.SizeOf(typeof(ConnMgrConnectionInfo)); } public ConnMgrConnectionInfo(Guid destination, ConnMgrPriority priority, ConnMgrProxy proxy) : this() { guidDestNet = destination; dwParams = ConnMgrParam.GuidDestNet; dwPriority = priority; dwFlags = proxy; } public ConnMgrConnectionInfo(Guid destination, ConnMgrPriority priority) : this(destination, priority, ConnMgrProxy.NoProxy) { } public ConnMgrConnectionInfo(Guid destination) : this(destination, ConnMgrPriority.UserInteractive) { } } |
约瑟夫让我走上了正确的道路。我找到了这个答案和后续链接,这些链接解释了如何使用 OMA 客户端配置来更改设备配置并最终允许我创建 GPRS 连接。
http://msdn.microsoft.com/en-us/bb737297
代码:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /// Creates a GPRS Connection with the specified name. /// </summary> /// <param name="name">The name of the connection to create.</param> public void Start(string name) { string xml ="<wap-provisioningdoc>" + "<characteristic type="CM_GPRSEntries">" + "<characteristic type="" + name +"">" + "<parm name="DestId" value="{436EF144-B4FB-4863-A041-8F905A62C572}" />" + "<parm name="UserName" value="" />" + "<parm name="Password" value="" />" + "<parm name="Domain" value="" />" + "<characteristic type="DevSpecificCellular">" + "<parm name="GPRSInfoValid" value="1" />" + "<parm name="GPRSInfoAccessPointName" value="internet.com" />" + "</characteristic>" + "</characteristic>" + "</characteristic>" + "</wap-provisioningdoc>"; XmlDocument configDoc = new XmlDocument(); configDoc.LoadXml(xml); XmlDocument result = ConfigurationManager.ProcessConfiguration(configDoc, true); } |
要创建或删除连接,请使用带有 wap 配置 xml 文件的 dmprocessconfig。 msdn 有这方面的例子
我没有任何GPRS设备,但它可以像关闭手柄和释放你打开的资源一样简单。
查看类似的问题:关闭 Windows Mobile 上的 GPRS 连接
出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
如何使用RSpec::Core::RakeTask初始化RSpecRake任务?require'rspec/core/rake_task'RSpec::Core::RakeTask.newdo|t|#whatdoIputinhere?endInitialize函数记录在http://rubydoc.info/github/rspec/rspec-core/RSpec/Core/RakeTask#initialize-instance_method没有很好的记录;它只是说:-(RakeTask)initialize(*args,&task_block)AnewinstanceofRake
我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以
关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion为什么SecureRandom.uuid创建一个唯一的字符串?SecureRandom.uuid#=>"35cb4e30-54e1-49f9-b5ce-4134799eb2c0"SecureRandom.uuid方法创建的字符串从不重复?
我使用的是Firefox版本36.0.1和Selenium-Webdrivergem版本2.45.0。我能够创建Firefox实例,但无法使用脚本继续进行进一步的操作无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055)错误。有人能帮帮我吗? 最佳答案 我遇到了同样的问题。降级到firefoxv33后一切正常。您可以找到旧版本here 关于ruby-无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055),我们在StackOverflow上找到一个类
我正在阅读SandiMetz的POODR,并且遇到了一个我不太了解的编码原则。这是代码:classBicycleattr_reader:size,:chain,:tire_sizedefinitialize(args={})@size=args[:size]||1@chain=args[:chain]||2@tire_size=args[:tire_size]||3post_initialize(args)endendclassMountainBike此代码将为其各自的属性输出1,2,3,4,5。我不明白的是查找方法。当一辆山地自行车被实例化时,因为它没有自己的initialize方法
如何在ruby中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL