Microsoft 或 Widcomm Stack 上的 Windows Mobile 蓝牙访问

发布于 2024-11-06 07:43:58 字数 380 浏览 0 评论 0原文

我有一个在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

前事休说 2024-11-13 07:43:58

我猜你可能必须动态地完成这一切:

  1. 在你自己的代码中声明必要的 Widcomm 函数的原型。
  2. 使用LoadLibrary加载Widcomm dll。
  3. 如果 LoadLibrary 调用失败,那么您就知道您位于 Microsoft 堆栈上,并且可以运行标准的 Microsoft 堆栈函数。
  4. 如果 LoadLibrary 成功,您就位于 Widcomm 堆栈上,并且可以使用 Widcomm 函数。

它可能有点混乱,具体取决于您需要从 Widcomm 标头中获取多少个函数,但是您无法静态编译对这些函数的引用,因为它会尝试加载它但找不到它(这可能就是您的原因)看到崩溃)。

蓝牙堆栈的疯狂现象也存在于 Windows Mobile 上,这确实很糟糕。认为这仅限于桌面。

I'm guessing you can have to do it all dynamically:

  1. Declare prototypes for the necessary Widcomm functions in your own code.
  2. Use LoadLibrary to load the Widcomm dll.
  3. If the LoadLibrary call fails then you know you're on a Microsoft stack and you can run the standard Microsoft stack functions.
  4. If the 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文