Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can i use WMI in Qt? cant get msdn sample to work properly in qt5.2
Forum Updated to NodeBB v4.3 + New Features

How can i use WMI in Qt? cant get msdn sample to work properly in qt5.2

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Coderx
    wrote on 31 Dec 2013, 17:52 last edited by
    #1

    I am trying to test an msdn sample on WMI notification in c++ which is located here: "Example: Receiving Event Notifications Through WMI ":http://msdn.microsoft.com/en-us/library/aa390425(v=vs.85).aspx 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:

    bq. Failed to initialize COM library. Error code = 0xffffffff80010106

    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?
    I even tried running those codes inside another thread like :
    @ std::thread t(&frmProcess::WMIMethod2,this);
    t.join();@
    where WMIMethod2 contains the code for executing wmi stuff as shown in the link provided above form msdn.
    If i do this i get this error :
    !http://i43.tinypic.com/289dlrr.jpg(Qt5.2 error )!
    What is wrong here and how can i solve this ?
    Regards

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 31 Dec 2013, 20:46 last edited by
      #2

      Hi,

      AFAIK, when using com objects, you still need to do the initialization yourself. And it seems (but I might be wrong) that you are trying to access GUI element from another thread which is not supported.

      I would rather try to encapsulate the WMI notifier in a QObject maybe move it to it's own thread if needed and emit signals from it to update the GUI

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Coderx
        wrote on 1 Jan 2014, 02:12 last edited by
        #3

        Thanks, Would it be possible for you to show me a small example of doing such a thing?

        1 Reply Last reply
        0

        1/3

        31 Dec 2013, 17:52

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved