Results 1 to 4 of 4

Thread: Problem with #include "windows.h"

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Unhappy Problem with #include "windows.h"

    I'm not sure if that would be a Qt programming question, but anyway.

    I want to create a software in Qt that do some things regarding process in Windows (see http://www.qtcentre.org/threads/4964...ocess?p=222983). I'm using Windows API functions to do what I want, at least for the moment.

    Now I'ld like to receive some data regarding the RAM memory consumption of a given process, what is taught how to do it here: http://stackoverflow.com/questions/6...side-a-process

    In a first moment I tried this codes in Borland C++ Builder; it worked fine.

    But when I ctr+c + ctrl+v the API code in Qt, I got some errors; essentially it seems that Qt is not recognizing the presence of the #include "windows.h", so it's not being able to recognize the variables the code needs to work.


    Code:
    Qt Code:
    1. #include "windows.h"
    2.  
    3. /.../
    4. /.../
    5.  
    6. MEMORYSTATUSEX memInfo;
    7. memInfo.dwLength = sizeof(MEMORYSTATUSEX);
    8. GlobalMemoryStatusEx(&memInfo);
    To copy to clipboard, switch view to plain text mode 

    Errors:
    15:20:27: Running build steps for project WD...
    15:20:27: Configuration unchanged, skipping qmake step.
    15:20:27: Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
    C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug
    mingw32-make.exe[1]: Entering directory `C:/Users/Endrigo/Desktop/Central350/trunk/central BD novo -v18.2.2/WD'
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.8.0\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.8.0\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.8.0\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.8.0\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.0\mingw\mkspecs\win32-g++" -o debug\main.o main.cpp
    main.cpp: In function 'int qMain(int, char**)':
    main.cpp:28: error: 'MEMORYSTATUSEX' was not declared in this scope
    main.cpp:28: error: expected ';' before 'memInfo'
    main.cpp:29: error: 'memInfo' was not declared in this scope
    main.cpp:30: error: 'GlobalMemoryStatusEx' was not declared in this scope
    main.cpp:39: error: 'ui' was not declared in this scope
    mingw32-make.exe[1]: Leaving directory `C:/Users/Endrigo/Desktop/Central350/trunk/central BD novo -v18.2.2/WD'
    mingw32-make.exe[1]: *** [debug/main.o] Error 1
    mingw32-make.exe: *** [debug] Error 2
    15:20:29: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project WD (target: Desktop)
    When executing build step 'Make'

    Thanks,


    Momergil
    Last edited by Momergil; 28th June 2012 at 20:56.

Similar Threads

  1. Replies: 1
    Last Post: 28th April 2012, 03:53
  2. Replies: 1
    Last Post: 5th February 2011, 21:14
  3. Replies: 4
    Last Post: 10th November 2009, 19:48
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. QFile Problem~ "Unknow error" in "open(QIODevice::ReadWrite)"
    By fengtian.we in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2007, 15:58

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.