Reputation: 25924
I am trying to test an msdn sample on WMI notification in c++ which is located here: Example: Receiving Event Notifications Through WMI in a Qt5.2 project.Everything compiles just fine and runs well, But when I try to run the sample code, I get stuck at the very beginning!
I get the error:
failed to initialize Com library
I\ve read somewhere that it seems Qt
itself initializes the com objects, So there is no need to re initialize it.
In that case if i comment the initialization part i get CoInitializeSecurity
failure error.!
What am i missing here?
Upvotes: 1
Views: 2930
Reputation: 25924
From MSDN:
The multi-threaded apartment is intended for use by
non-GUI
threads. Threads in multi-threaded apartments should not perform UI actions. This is because UI threads require a message pump, and COM does not pump messages for threads in a multi-threaded apartment.
Instead of a GUI application in qt, i tried a console based one and it worked.
Upvotes: 1