开发者

Windows Mobile Bluetooth access on either Microsoft or Widcomm Stack

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?

Questio开发者_StackOverflow中文版n 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜