After reading various posts on this forum, I decided to use the non-ATL approach to support the SpaceNavigator from my C++ application. When the device is connected, everything works fine.
On some computers, where the SpaceNavigator is not currently connected, the initialization hangs for about 5 seconds - obviously an annoying delay for our users. I have narrowed it down to the CreateInstance method which is where the 5 second delay happens. This is a snippet from my code:
- Code: Select all
// Initialize COM
HRESULT hr = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
// Create the device object
hr = device.CreateInstance(__uuidof(Device)); // THIS TAKES ABOUT 5 SECONDS!
// Get the interfaces to the sensor and the keyboard
sensor_ = device->Sensor;
keyboard_ = device->Keyboard;
// Associate a configuration with this device (not sure what this does)
// Connect to the driver
Does anyone have a clue why this is happening and what I can do to prevent it? Note that the code runs through completely even if the device is not connected, so CreateInstance is apparently successful but slow in this case.