Microsoft 或 Widcomm Stack 上的 Windows Mobile 蓝牙访问
我有一个在 Windows 移动设备上运行的 Java 应用程序。我需要能够打开和关闭蓝牙,以便它执行一些本机代码来执行此操作。问题是我正在新设备(HTC HD2)上尝试它,并且本机代码不起作用。原因是 HD2 设备使用 Widcomm 蓝牙堆栈,而另一个设备使用 Microsoft 堆栈。
我现在找到了一种使用 Widcomm SDK 在 HD2 设备上激活蓝牙的方法。然而,这个本机代码需要能够在任何设备上运行,因此我需要能够在运行时根据存在的蓝牙堆栈来决定运行哪些代码。
问题 1:如何以编程方式确定存在哪个堆栈?
问题 2:如果我包含 Widcomm 堆栈所需的头文件并尝试在不使用它的设备上运行它,则代码会失败。如果 Widcomm dll 存在,如何编译 dll,使其仅包含该头文件?
I have a Java application that is running on a Windows mobile device. I need to be able to turn Bluetooth on and off so it is executing some native code to do this. The problem is that I am trying it out on a new device (the HTC HD2) and the native code doesn't work. The reason for this is that the HD2 device is using the Widcomm Bluetooth stack, whereas the other device was using the Microsoft stack.
I have now found a way of activating Bluetooth on the HD2 device using the Widcomm SDK. However this native code needs to be able to run on any device, so somehow I need to be able to make the decision at runtime which code to run based on which bluetooth stack is present.
Question 1: how can I determine programmatically which stack is present?
Question 2: if I include the header file required for the Widcomm stack and try to run it on a device that doesn't use it the code fails. How can I compile the dll so that it only includes that header file if the Widcomm dll exists?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你可能必须动态地完成这一切:
LoadLibrary
加载Widcomm dll。LoadLibrary
调用失败,那么您就知道您位于 Microsoft 堆栈上,并且可以运行标准的 Microsoft 堆栈函数。LoadLibrary
成功,您就位于 Widcomm 堆栈上,并且可以使用 Widcomm 函数。它可能有点混乱,具体取决于您需要从 Widcomm 标头中获取多少个函数,但是您无法静态编译对这些函数的引用,因为它会尝试加载它但找不到它(这可能就是您的原因)看到崩溃)。
蓝牙堆栈的疯狂现象也存在于 Windows Mobile 上,这确实很糟糕。认为这仅限于桌面。
I'm guessing you can have to do it all dynamically:
LoadLibrary
to load the Widcomm dll.LoadLibrary
call fails then you know you're on a Microsoft stack and you can run the standard Microsoft stack functions.LoadLibrary
succeeds you're on the Widcomm stack and can use the Widcomm functions.It might be a bit messy depending on how many functions you need from the Widcomm header, but you can't statically compile in references to those functions, as it will try and load it and not find it (which is probably why you're seeing the crash).
That's truly terrible that the Bluetooth stack craziness exists on Windows Mobile as well. Thought that was confined to the desktop.