Results 1 to 20 of 32

Thread: QT WMI Classes

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2010
    Location
    UAE
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default QT WMI Classes

    Greetings to Everybody:
    I want to use WMI Classes in QT/2009.05 C++ but I do not know how to, I am using QT seperately mean without Eclipse, VS or anything...
    I want to create a System Restore point using QT/C++ but not able to do it...in VB it is simple two line like
    Qt Code:
    1. Set SRP = GetObject( "winmgmts:\\.\root\default:Systemrestore" )
    2. CSRP = SRP.CreateRestorePoint( "Hacked the registry", 0, 100 )
    To copy to clipboard, switch view to plain text mode 

    but when I use in QT like
    Qt Code:
    1. #include <comdef.h>
    2. #include <Wbemidl.h>
    3. #define _WIN32_DCOM
    4. #include <iostream>
    5. using namespace std;
    6. #include <comdef.h>
    7. #include <Wbemidl.h>
    8.  
    9.  
    10. # pragma comment(lib, "wbemuuid.lib")
    11.  
    12.  
    13. int main(int argc, char **argv)
    14. {
    15. HRESULT hres;
    16.  
    17.  
    18. // Step 1: --------------------------------------------------
    19. // Initialize COM. ------------------------------------------
    20.  
    21.  
    22. hres = CoInitializeEx(0, COINIT_MULTITHREADED);
    23. if (FAILED(hres)) .........
    To copy to clipboard, switch view to plain text mode 
    then it gives errors like
    Wbemidl.h no such file or directory...
    comdef.h no such file or directory...
    CoIntialize is not declared in this context...

    Please help me, how can I use WMI classes in QT/2009.05/C++ . Also let me know if I have to add some libraries or something...
    Any help would be appreciated.
    Many thanks in advance

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

    Default Re: QT WMI Classes

    Your project is not configured to find the WMI environment.
    You have to add to your pro file (or project configuration under MSVS) the include and lib paths, as well as the libs you are linking against.
    ==========================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.

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

    Default Re: QT WMI Classes

    Thanks alot for your reply, but I am not using QT with MSVS, so is there any way arround to let QT go without MSVS or I have to use it anyway.
    and if yes then would you please tell me how to configure/include the WMI lib paths...in MSVS/QT
    Any help would be a great favour.
    thanks in advance.

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

    Default Re: QT WMI Classes

    Read my post again, I only mentioned MSVC in case you were using it.
    You have to add the include and lib paths to you pro file.
    Don't forget to specify the libs to link against.
    ==========================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.

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

    Default Re: QT WMI Classes

    Dear I have already added libs path in QT but no success in my .pro like
    Qt Code:
    1. LIBS += WbemUuid.Lib \
    2. LIBS += C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib\WbemUuid.Lib
    To copy to clipboard, switch view to plain text mode 
    I have used both the above ways but no success.

    If you know how to then why you not write me a short code or paste your .pro file in which you have done it...
    or let me know how I can do it step by step.
    Please do not think me that I am expert in QT I am just using it since three weeks or so...
    So please help me to done it.

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

    Default Re: QT WMI Classes

    f you know how to then why you not write me a short code or paste your .pro file in which you have done it...
    Because we are not here to do your work for you, but to help you learn how to do it your self.
    Besides, I don't know which libs you want to link and where they are on your system, which is almost all the info you have to type anyway.

    Your syntax is wrong for the lib path.
    Read here on how to specify linkage libs and paths.

    Oh, and you also have to add the include paths!!
    ==========================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.

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

    Default Re: QT WMI Classes

    If my syntax is wrong for Lib path then why does not QT gives error or something to notify me that I am doing that bit wrong ? is it a bug in QT ?
    and as you said you are here to help others then try to be polite with others not rude and please in reply use some useful things not only description like do this and do this give some examples as well, which will help others to learn who are not well familiar with QT.
    And I already told you that I need WMI classes so I need WMI library. Please write some sort of code examples if you know.

  8. #8
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT WMI Classes

    justatiq, IMHO, there is the problem
    Qt Code:
    1. ...
    2. # include <Wbemidl.h>
    3. ...
    4. # Pragma comment (lib, "wbemuuid.lib")
    To copy to clipboard, switch view to plain text mode 

    Let me explain (IMHO): these headers <Wbemidl.h> and the library "wbemuuid.lib" is used only for MSVS compiler (but you're using MinGW). Ie This library is the wrappers on the shared libraries from the /Windows/System32/.
    ie WMI classes really need is in the system *. dll Windows - and you just Use QLoader to access the *. dll.
    ie you try to determine in what their *. dll are required for you classes WMI. Read what is said in MSDN on this subject.

    PS: I may be mistaken.

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

    Default Re: QT WMI Classes

    Hi kuzulis:
    Nice to see your reply and it really helped me to boost my moral. I went on MSDN and read about WMI Classes but they have the same code as I have mentioned in my first Post.
    But I found one line in the comment i.e.
    Qt Code:
    1. add #pragma comment(lib, "comsuppw.lib") line
    To copy to clipboard, switch view to plain text mode 
    and one more thing they stated that, the above mentioned code is working in latest vc++. I think I should install Microsoft Visual Studio 2008 ?
    Please let me know am I going on the right track or not ?
    As you said WMI Classes really need is in the system *.dll windows - and you just use QLoader to access the *.dll
    Would you please tell me which files should i put in System or system32 and which files I load using Qloader (Please do not mind my silly questions - I do not know much about QT)

    and again thanks for your help.

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

    Default Re: QT WMI Classes

    Quote Originally Posted by justatiq View Post
    is it a bug in QT ?
    No, it is not. And it's Qt, not QT.
    and as you said you are here to help others then try to be polite with others not rude and please in reply use some useful things not only description like do this and do this give some examples as well, which will help others to learn who are not well familiar with QT.
    Please read qmake documentation if you haven't already done so. Also please browse the net searching for a general answer what to do when a compiler issues a "no such file or directory" error.
    And I already told you that I need WMI classes so I need WMI library. Please write some sort of code examples if you know.
    Please read WMI documentation on how to enable it in your projects.

    Examples for respective problems will be found in documentation for each of the components.

    You can't just shoot blindly hoping to find a proper solution by chance.
    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.


  11. #11
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT WMI Classes

    justatiq,

    here's a link how to make the example of Delphi: http://www.delphikingdom.com/asp/vie...?catalogid=698

    I think along the lines you do.

    PS:
    1. only for you there is one problem - article in Russian . But do not worry - use translate.google
    2. even as an option - look for something similar in your language.

  12. #12
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT WMI Classes


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

    Default Re: QT WMI Classes

    Quote Originally Posted by kuzulis View Post
    There is ActiveQt, you know...
    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.


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

    Default Re: QT WMI Classes

    Kuzulis:
    Your replies are really helping me to go ahead... thanks for all that.
    Dear I have already a complete project and also working in Delphi with WMI and have no problems at all. even I can do it in VB script ...

    But now I want to do the same in Qt but do not know how ?

    Here are many people who come and comments do this and do this.. but they do not tell how ? like you give me some key points, thanks for that.
    Dear if you have something related to Qt then please let me know more.

    to wysota:
    I have googled but did not find any solutions (I think you also tried) thats why i put the question here, if you do not know then this is not my fault... I put the question for those who knows.
    It is very easy to pin point mistakes of others but I think difficult to write code what is requied... I think you need not to come and pick something from the replies and distrub others.
    so if you do not know then please keep away. sorry for any mistakes Many thanks

Similar Threads

  1. QSkinWindows Classes
    By kernel_panic in forum Qt-based Software
    Replies: 45
    Last Post: 20th April 2010, 12:35
  2. fax classes in qt
    By dyams in forum Qt Programming
    Replies: 5
    Last Post: 7th September 2007, 09:14
  3. Why does Qt use Private classes?
    By hyling in forum Qt Programming
    Replies: 2
    Last Post: 12th December 2006, 22:11
  4. Doxygen and Qt Classes
    By chaosgeorge in forum Qt Programming
    Replies: 6
    Last Post: 10th December 2006, 00: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.