출력
 
Total : 2096236 free : 1242116


소스
#include <Windows.h>
#include <iostream>

struct ST_MemLog
{
        ULONG   totalMem;
        ULONG   freeMem;
};


bool    getMemLog( ST_MemLog * pMemLog )
{
        static const long       KBYTE = 1024;

        MEMORYSTATUSEX statex;

        statex.dwLength = sizeof (statex);

        if( GlobalMemoryStatusEx( &statex ) == FALSE )
                return false;

        // total Kbytes of physical memory
        pMemLog->totalMem = static_cast<ULONG>( statex.ullTotalPhys / KBYTE );

        // free Kbytes of physical memory.
        pMemLog->freeMem = static_cast<ULONG>( statex.ullAvailPhys / KBYTE );

        return true;
}

int main( int argc, char * argv[] )
{
        ST_MemLog       memLog;

        if( getMemLog( &memLog ) ) {
                cout << "Total : " << memLog.totalMem <<
                        "\tfree : " << memLog.freeMem << endl;
        }
        cout << "\t\thttp://fehead.tistory.com\n";

        return 0;
}


+ Recent posts