Page 1 of 2 12 LastLast
Results 1 to 20 of 32

Thread: QT WMI Classes

  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,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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

  15. #15
    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

    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.
    You are missing the point.
    People are giving you pointers so that you can know what to look for in the documentation and READ and LARN from it.
    No one is going to chew anything for you.
    So if wysota says "ActiveQt", it means, you have to open the documentation about ActiveQt, and then you will KNOW.

    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.
    be careful.
    look at the wysotas statistics on this forum.
    You will see, that appart from being the top poster here, you can see also see how many thanked posts he has, which would tell you, that when it comes to Qt, he knows and helps A LOT!

    Posting questions on the forum is good and nice, but you have to use the help you get, and not complain about people not supllying you wiht the full solution to your problem!
    ==========================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.

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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
    But now I want to do the same in Qt but do not know how ?
    I think the problem is you are expecting to be given a complete piece of working code that does what you want. Which is unlikely to happen If you know how to do the thing in Delphi or VB then just port the same idea to C++. Qt won't help you much here as it is meant mainly for cross-platform solutions and obviously what you are trying to do is not cross-platform. If the module you are trying to access has a (D)COM interface (and from what I see it probably does) then you can use ActiveQt to use it. If it doesn't have a COM interface then I'm sure MSDN contains at least one snippet of code showing how to use WMI in C++. It may not do exactly what you want and in such case you have to adapt the code to do what you need (i.e. call a different routine from the library).
    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.


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

    Default Re: QT WMI Classes

    Quote Originally Posted by wysota View Post
    I'm sure MSDN contains at least one snippet of code showing how to use WMI in C++.
    Yes you are right, there is a snippet for that... and I did that but I got some errors which are reported in my first post at the top.

    I would like to tell that I do not need complete code or any piece of code I just want to configure Qt with WMI, I tried alot but still getting errors (sometime library not found sometime no such file or directory, same errors as reported in first post).
    I would be very thankful if somebody tell me how can I configure Qt with WMI, I do not need code, once I configure Qt to use WMI code I will do coding at my end. I have already done in delphi but Qt and delphi are different (as for as I know) as in Delphi there is a way to use WMI Classes... something like that
    Delphi:
    Project -> Import type library
    select Microsoft WMI script v1.2 library
    install it
    and you are able to use WMI classes in Delphi.
    I thought there would be something similar in Qt and this is what I am trying to ask other people on this forum not any code.
    If someone knows that then please let me know how can I do that in Qt.
    Thanks in advance.

  18. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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
    Yes you are right, there is a snippet for that... and I did that but I got some errors which are reported in my first post at the top.
    So fix them, A missing file from Windows SDK doesn't have anything to do with Qt.

    I would be very thankful if somebody tell me how can I configure Qt with WMI
    What do you mean by "configure Qt with WMI"?
    I thought there would be something similar in Qt and this is what I am trying to ask other people on this forum not any code.
    Again, Qt has nothing to do with this. Create a new project, strip it all of Qt code and focus on including the offending file. Before other things, check if you have this file on your disk at all and where it is.
    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.


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

    Default Re: QT WMI Classes

    Quote Originally Posted by wysota View Post
    What do you mean by "configure Qt with WMI"?
    I mean to use WMI Classes using Qt, If I write some code which is pointing to WMI classes like
    Qt Code:
    1. #include <Wbemidl.h>
    To copy to clipboard, switch view to plain text mode 
    then it should work but it does not work. and I think you did not read all the posts. because no file is missing all are on my computer and I can see them but when I reference them then Qt does not find them and gives error.
    Create a new project, strip it all of Qt code and focus on including the offending file. Before other things, check if you have this file on your disk at all and where it is.
    I have done this and I have all the files but Qt is not finding them. I am getting error like there is no file or directory (but the file is there) then after this I have error on CoIntializeEx...
    I request you to read all the posts and then reply because whatever you have said has already been discussed at the top.
    So please try to help on configuring Qt with WMI. Can you please try at your PC ?
    Thanks
    Last edited by justatiq; 14th March 2010 at 10:28.

  20. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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
    then it should work but it does not work
    And what does Qt have to do with this?

    and I think you did not read all the posts. because no file is missing all are on my computer and I can see them but when I reference them then Qt does not find them and gives error.
    "Qt" does not look for any files. Your compiler does. So tell your compiler where the file is instead of blaming Qt for things it has nothing to do with. Locate the file in question and see if it is in your compiler include search path. If not then either reference it in your code using a path that the compiler (or the C preprocessor, to be exact) can resolve (i.e. using an absolute path or path relative to one of the search paths of your compiler) or add the path where the file resides to your compiler search path (you can do that for a specific project using QMake's INCLUDEPATH variable).
    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.


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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.