Does anyone know of a function that detects the amount of physical memory in a machine.
Cheers
Peter
P.S this is to run under windows
Printable View
Does anyone know of a function that detects the amount of physical memory in a machine.
Cheers
Peter
P.S this is to run under windows
Code:
#include <windows.h>
//return total memory NOT available memory
long memsize(){
MEMORYSTATUS size;
long i;
size.dwLength = sizeof(MEMORYSTATUS);
i=GlobalMemoryStatus(&size);
return size.dwTotalPhys;
}
Do you know how to do it without using windows.h?(I dislike windows.h) You use interrupts. If you wanted to find the memory on a different platform, say DOS, you would need interrupts. I was just trying to find out how to do this, but at the moment, I can't find the actual Interrupt number you use. Here's the basic framework... :
#include <dos.h>
union REGS i, o;
/* These are basically arguments. Some interrupt numbers have
* several subfunction numbers... Usually, you only use AX or BX,
* but, for some functions, you may need the others. */
i.x.ax = ?;
i.x.bx = ?;
i.x.cx = ?;
i.x.dx = ?;
int86(intnuminhex, &i, &o);
var = o.x.ax;
/* Put the value of ax in var... This would be the amount of RAM if
* you found the interrupt number you need by searching on the
* net... */
There are some interrupt lists which have all of the interrupts out there...
WarM -
You should find abdul's post about using asm, calling 'Interrupts'.
I have a different point of view from you two, but that's just fine.
Why, am I that bad???
Is it about the int86(int,i,o) thing or is it about my sig? :rolleyes: