Momergil
28th June 2012, 20:21
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/49644-How-to-command-other-process?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/63166/how-to-determine-cpu-and-memory-consumption-from-inside-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:
#include "windows.h"
/.../
/.../
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
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\QtCore" -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
I want to create a software in Qt that do some things regarding process in Windows (see http://www.qtcentre.org/threads/49644-How-to-command-other-process?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/63166/how-to-determine-cpu-and-memory-consumption-from-inside-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:
#include "windows.h"
/.../
/.../
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
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\QtCore" -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