Hi guy's.I'm kind a new to C:B.I have some problems compiling a function that get the free available memory.Here is my little code:
mem_load.cpp:
#include "mem_load.h"
DWORDLONG memory_load()
{
MEMORYSTATUSEX statex;
statex.dwLength = sizeof (statex);
GlobalMemoryStatusEx (&statex);
return (statex.ullAvailPhys/DIV);
}
Here's the mem_load.h:
#ifndef MEM_LOAD_H_INCLUDED
#define MEM_LOAD_H_INCLUDED
#include <windows.h>
typedef struct _MEMORYSTATUSEX {
DWORD dwLength;
DWORD dwMemoryLoad;
DWORDLONG ullTotalPhys;
DWORDLONG ullAvailPhys;
DWORDLONG ullTotalPageFile;
DWORDLONG ullAvailPageFile;
DWORDLONG ullTotalVirtual;
DWORDLONG ullAvailVirtual;
DWORDLONG ullAvailExtendedVirtual;
} MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
#define DIV 1024
DWORDLONG mem_info();
#endif // MEM_LOAD_H_INCLUDED
And again the source code for the main.cpp:
#include <iostream>
#include "mem_load.h"
using namespace std;
int main()
{
DWORDLONG meminfo=mem_info();
cout << meminfo << endl;
return 0;
}
Now when i try to compile this,i get this error message:
C:\CodeBlocks\SystemInfo\mem_load.cpp||In function `DWORDLONG mem_info()':|
C:\CodeBlocks\SystemInfo\mem_load.cpp|9|error: `GlobalMemoryStatusEx' was not declared in this scope|
C:\CodeBlocks\SystemInfo\mem_load.cpp|9|warning: unused variable 'GlobalMemoryStatusEx'|
||=== Build finished: 1 errors, 1 warnings ===|
I must say that at the C:B menu Settings -> compiler and debugger-->search directories->linker tab ,i add this path:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib //for the kernel32.lib
C:\Windows\System32 //for the kernel32.dll
Please help me if you can i don't anymore know what to do,i done a lot of search with google but i couldn't find anything to help me!
Some people said that before #include <windows.h> add this:#define WINVER 0x0500 but that get me more errors!
So please give a hand of help!
Please excuse my bad english!