Page 2 of 2 FirstFirst 12
Results 21 to 32 of 32

Thread: QT WMI Classes

  1. #21
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QT WMI Classes

    To summarise for justatiq:
    • The C++ compiler needs to be able to find include files that you do not specify a complete path to, e.g Wbemidl.h. You are using MingW, try issuing
      Qt Code:
      1. gcc -v -c helloworld.c
      To copy to clipboard, switch view to plain text mode 
      to see where it will look by default. The GNU C++ compiler uses "-I" options to add to the include search path.
    • "#pragma" directives in source files are compiler specific. Any example on the Microsoft site is specific to their compiler but can give you some hints as to which libraries to link.
    • The linker needs to be know which libraries must be linked to satisfy calls you have made, e.g. wbemuuid.lib. The GNU ld linker uses option "-l" (lower case L) for this.
    • The linker needs to be able to find libraries to satisfy calls you have made. The GNU ld linker uses option "-L" for this. The default search path is built in. In MingW's case it will be limited to stuff inside MingW.
    • Spaces in paths need careful quoting.

    These problems are generic compile/link problems and not Qt related.

    The qmake system can help invoke the compiler correctly once you know the necessary include paths, library search path, and library names:
    • You can adjust the INCLUDEPATH in a Qt Pro file help the compiler find include files.
    • You can adjust the LIBS in a Qt Pro file help the linker find library files but you need to get the syntax right.

    In Assistant, under "QMake Manual", look at the section headed "qmake Reference"
    Last edited by ChrisW67; 15th March 2010 at 01:46.

  2. #22
    Join Date
    Feb 2010
    Location
    UAE
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: QT WMI Classes

    Qt has to provide me with something I can configure like delphi does... as I mentioned in my previous post that I can easily use WMI after some settings
    and I am not blaming Qt but Qt should provide this or tell me how ?

    Yes I know it is compiler who looks for the files( I just said for the argument only).
    I have used all the paths, absolute paths but the problem is not solved yet.
    But I am trying and hopefully it would be solved.

  3. #23
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QT WMI Classes

    Quote Originally Posted by justatiq View Post
    Qt has to provide me with something I can configure like delphi does...
    Qt is a library.

    If you buy a car, the producer doesn't supply you with a parking lot, mechanic workshop, garage, streets or a camping compartments to hook up to your brand new car. You have to take care of such things yourself.

    as I mentioned in my previous post that I can easily use WMI after some settings
    and I am not blaming Qt but Qt should provide this or tell me how ?
    Any tool you use won't magically determine where respective files are located on your system (and if they are there at all). If you are not up to the task of locating them yourself, maybe you should pay someone to do it for you.

    Yes I know it is compiler who looks for the files( I just said for the argument only).
    So why involve Qt in this? Leave Qt out for now, first be able to compile any C/C++ application that uses WMI and only then add Qt to the equation.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #24
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QT WMI Classes

    Qt has to provide me with something I can configure like delphi does...
    The bundled compiler you are using "can easily use WMI after some settings", it is just that the settings you crave are not some pretty, no-brainer check box but a few entries in a configuration file. Delphi's configuration is telling it to use the relevant COM object. C++ is not Deplhi; you will have to do a lot of what the Delphi IDE is hiding from you by yourself.

    I have used all the paths, absolute paths but the problem is not solved yet. But I am trying and hopefully it would be solved.
    Then there is still something wrong in your paths or the way you have tried to use them. You have not posted much about what you have actually tried so potential helpers can only guess.

    Have you tried building a basic WMI example without Qt involved i.e. single file and generic gcc/g++ commands? When you succeed at this you will have gained an insight into how to roll WMI into a wider Qt-based project. Then you should use a simple Qt project to combine with WMI, just read something and print it, before moving on to a larger project.

    Your 4 Feb 2010 post indicated that you had not quite grasped the LIBS variable in your pro file and you were given guidance that the syntax was wrong. Have you fixed that? Did you look at the suspect path I pointed out? What do the relevant parts of the pro file look like? Have the error messages from your build changed?

    There ultimately should be bits something like:
    Qt Code:
    1. INCLUDEPATH += "Q:\...\...\include"
    2. LIBS += -L"Q:\...\Microsoft SDKs\Windows\...\lib" -lwbemuuid -l... -l...
    To copy to clipboard, switch view to plain text mode 
    All of these suggestions have already been made, but the specifics are left for you to fill in.

  5. #25
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: QT WMI Classes

    @justatiq
    Did you ever tried Qt Assistant? I guess you did not... It took me aprox 1min 30s to find answer to your question in Assistant. It is rather faster than 1.5month (it is time elapsed from thread start) so take those advices you got here and RTFM!
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  6. #26
    Join Date
    Jun 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: QT WMI Classes

    Hi I've this code and it's working fine on Qt 4.6.3 but if I use Qt 4.7 this function returns me nothing. What am I doing wrong ?

    Qt Code:
    1. std::string DMI::wmiquery(std::string domain, std::string field)
    2. {
    3. std::string ret;
    4.  
    5. if (!objWMIService)
    6. {
    7. Log::RegistrarEvento("Leitura abortada: WMI não inicializado.");
    8. return ret;
    9. }
    10.  
    11. //Attempt to use some WMI functions...
    12. QAxObject *returnList = objWMIService->querySubObject("ExecQuery(QString&)",
    13. QString("select * from %1").arg(domain.c_str()));
    14.  
    15. QAxObject * result = returnList->querySubObject("ItemIndex(int)", 0);
    16. result = result->querySubObject("Properties_()");
    17.  
    18. QAxObject *enum1 = result->querySubObject("_NewEnum");
    19. IEnumVARIANT* enumInterface; //to get this, include <windows.h>
    20. QUuid uuid("{00020404-0000-0000-C000-000000000046}");
    21. enum1->queryInterface(uuid, (void**)&enumInterface);
    22.  
    23. QString text;
    24.  
    25. enumInterface->Reset(); //start at the beginning of the list.
    26. for (int i=0;i<result->property("Count").toInt();i++)
    27. {
    28. VARIANT theItem;
    29. unsigned long count;
    30. enumInterface->Next(1,&theItem,&count);
    31. if (!count)
    32. break;
    33. QAxObject *bla = new QAxObject((IUnknown *)theItem.punkVal);
    34. // The problem is here.. the Property Name or any other property has empty value
    35. if (field == QString(bla->property("Name").toString().toLatin1().data()).trimmed().toStdString())
    36. {
    37. ret = QString(bla->property("Value").toString().toLatin1().data()).trimmed().toStdString();
    38. break;
    39. }
    40. }
    41.  
    42. return ret;
    43. }
    To copy to clipboard, switch view to plain text mode 

    thx,

  7. #27
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QT WMI Classes

    What am I doing wrong ?
    1. Poting on the wrong thread (just bacuse your problem has to do with WMI doesn't mean any other thread that has to do with it it a proper place for it).
    2. Do some research you self, and tell us the resutls for exmple:
    I have stepped through the code in the debugger and saw that 'objWMIService' is null.
    I then check my code where 'objWMIService' should be initialized, and it is.
    OR
    I have stepped through the code in the debugger and saw that result->property("Count") retuns 0,
    but I have no idea where the property list is filled to check why it is empty...
    Or any other stuff you actually tried to solve YOUR problem - before just laying it for us to do for you!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #28
    Join Date
    Jun 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT WMI Classes

    Quote Originally Posted by high_flyer View Post
    1. Poting on the wrong thread (just bacuse your problem has to do with WMI doesn't mean any other thread that has to do with it it a proper place for it).
    2. Do some research you self, and tell us the resutls for exmple:

    OR

    Or any other stuff you actually tried to solve YOUR problem - before just laying it for us to do for you!
    I don't think so. This thread is: How to use WMI, I shown what I did to solve it. I just forgot to mention this part:

    Qt Code:
    1. #ifndef WIN32
    2. #include <QProcess>
    3. #endif
    4. #include <ctype.h>
    5. #include <algorithm>
    6. #include <QMessageBox>
    7. #include <QList>
    8. #include <QByteArray>
    9. #include <QVariant>
    10. #ifdef WIN32
    11. QAxObject *DMI::objIWbemLocator;
    12. QAxObject *DMI::objWMIService;
    13. #endif
    14.  
    15. DMI::DMI(void)
    16. {
    17. }
    18.  
    19. void DMI::Initialize(void)
    20. {
    21. #ifdef WIN32
    22. CoInitialize(0);
    23.  
    24. //get the locator object
    25. objIWbemLocator = new QAxObject("WbemScripting.SWbemLocator");
    26.  
    27. //get the main WMI Service
    28. objWMIService = objIWbemLocator->querySubObject("ConnectServer(QString&,QString&)",QString("."),QString("root\\cimv2"));
    29. #endif
    30. }
    To copy to clipboard, switch view to plain text mode 

    That it's all what you need to do to communicate by WMI with Windows on Qt.

    I don't give more details because this code worked in Qt 4.6.3 and stops to work in Qt 4.7.2 without any apparently error.

    I said what I did, on commented code. All worked perfectly but the properties have no Value. I really don't know what I can do or which Qt 4.7.2 change affect the properly behavior of QAxObject.

    Qt Code:
    1. QAxObject *bla = new QAxObject((IUnknown *)theItem.punkVal);
    To copy to clipboard, switch view to plain text mode 

    bye and sorry.

  9. #29
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QT WMI Classes

    Make sure this is really caused by a change to 4.7 as it is very unlikely. Maybe something else has also changed in your system apart Qt.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #30
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QT WMI Classes

    I said what I did, on commented code.
    Ok, now I see it (would be a good idea to state in the question that there are comments about your findings in the code).
    I did react a bit hard since in recent times there a really a lot of people posting with out putting any thought of their own in to their own problems, expecting to be spoon fed - and since I read the forum between while I build, I read fast and often miss details - so I got a bit edgy.
    Sorry about that.

    Why do you use the following:
    Qt Code:
    1. i if (field == QString(bla->property("Name").toString().toLatin1().data()).trimmed().toStdString())
    2. {
    3. ret = QString(bla->property("Value").toString().toLatin1().data()).trimmed().toStdString();
    4. break;
    5. }
    To copy to clipboard, switch view to plain text mode 
    and not
    Qt Code:
    1. if (field == bla->property("Name").toString().trimmed().toStdString())
    2. {
    3. ret = bla->property("Value").toString().trimmed().toStdString();
    4. break;
    5. }
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. #31
    Join Date
    Jun 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT WMI Classes

    Quote Originally Posted by high_flyer View Post
    Ok, now I see it (would be a good idea to state in the question that there are comments about your findings in the code).
    I did react a bit hard since in recent times there a really a lot of people posting with out putting any thought of their own in to their own problems, expecting to be spoon fed - and since I read the forum between while I build, I read fast and often miss details - so I got a bit edgy.
    Sorry about that.

    Why do you use the following:
    Qt Code:
    1. i if (field == QString(bla->property("Name").toString().toLatin1().data()).trimmed().toStdString())
    2. {
    3. ret = QString(bla->property("Value").toString().toLatin1().data()).trimmed().toStdString();
    4. break;
    5. }
    To copy to clipboard, switch view to plain text mode 
    and not
    Qt Code:
    1. if (field == bla->property("Name").toString().trimmed().toStdString())
    2. {
    3. ret = bla->property("Value").toString().trimmed().toStdString();
    4. break;
    5. }
    To copy to clipboard, switch view to plain text mode 
    Hi.. I've installed the Qt 4.6.2 to continue developing. Today I install the current version of Qt (4.7.0). If I replace my code for yours the problem persist, all bla's properties have null value.

  12. #32
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QT WMI Classes

    If I replace my code for yours the problem persist, all bla's properties have null value.
    My code was not supposed to change anything in the functionality, which is exactly the point!
    I asked why you used your code the way you did (with (what seems to be) superfluous conversions)
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QSkinWindows Classes
    By kernel_panic in forum Qt-based Software
    Replies: 45
    Last Post: 20th April 2010, 13:35
  2. fax classes in qt
    By dyams in forum Qt Programming
    Replies: 5
    Last Post: 7th September 2007, 10:14
  3. Why does Qt use Private classes?
    By hyling in forum Qt Programming
    Replies: 2
    Last Post: 12th December 2006, 23:11
  4. Doxygen and Qt Classes
    By chaosgeorge in forum Qt Programming
    Replies: 6
    Last Post: 10th December 2006, 01:38

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.