Page 1 of 1

Establecer memoria de almacenamiento

Posted: Tue Sep 01, 2009 9:25 am
by Antonio Linares
Estas funciones os permiten reducir el tamaño de almacenamiento y asi incrementar la memoria libre:

Code: Select all

typedef BOOL  ( __stdcall * GetSystemMemoryDivisionProc )( LPDWORD, LPDWORD, LPDWORD );
typedef DWORD ( __stdcall * SetSystemMemoryDivisionProc )( DWORD );

HB_FUNC( GETMEMDIVISION )
{
    HINSTANCE hCoreDll = LoadLibrary(_T("coredll.dll"));
    GetSystemMemoryDivisionProc procGet = 
        (GetSystemMemoryDivisionProc)GetProcAddressW(
        hCoreDll, _T("GetSystemMemoryDivision"));

    DWORD dwStoragePages;
    DWORD dwRamPages;
    DWORD dwPageSize;

    procGet( &dwStoragePages, &dwRamPages, &dwPageSize );
    
    hb_reta( 3 );
    hb_stornl( dwStoragePages, -1, 1 );
    hb_stornl( dwRamPages, -1, 2 );
    hb_stornl( dwPageSize, -1, 3 );

    FreeLibrary( hCoreDll );
}

HB_FUNC( SETMEMDIVISION )
{
    int nStoragePages = hb_parnl( 1 );

    HINSTANCE hCoreDll = LoadLibrary(_T("coredll.dll"));
    SetSystemMemoryDivisionProc procSet = 
        (SetSystemMemoryDivisionProc)GetProcAddressW(
        hCoreDll, _T("SetSystemMemoryDivision"));

    hb_retnl( procSet( nStoragePages ) );

    FreeLibrary(hCoreDll);
}

#pragma ENDDUMP
 
Explicación aqui:
http://www.pocketpcdn.com/articles/memorydivision.html