系统相关
首页 > 系统相关> > WinCE动态调整存储内存与程序内存的大小

WinCE动态调整存储内存与程序内存的大小

作者:互联网

typedef DWORD (*SETSYSTEMMEMORYDIVISION)(DWORD);
typedef BOOL  (*GETSYSTEMMEMORYDIVISION)(LPDWORD,LPDWORD,LPDWORD);
void SetObjectMemorySpace(int nSize)//设置存储内存为nSize字节的容量
{
#ifdef _WIN32_WCE
    //从动态库中获取函数地址以设置对象存储区的大小.
    HINSTANCE hDll = LoadLibrary(_T("Coredll.dll"));
    SETSYSTEMMEMORYDIVISION    SetSystemMemoryDivisionProc = NULL;  
    GETSYSTEMMEMORYDIVISION    GetSystemMemoryDivisionProc = NULL;  
    if( NULL != hDll )
    {
        //获取导出函数地址
        SetSystemMemoryDivisionProc = (SETSYSTEMMEMORYDIVISION)GetProcAddress(hDll,_T("SetSystemMemoryDivision"));
        GetSystemMemoryDivisionProc = (GETSYSTEMMEMORYDIVISION)GetProcAddress(hDll,_T("GetSystemMemoryDivision"));
        if(SetSystemMemoryDivisionProc && GetSystemMemoryDivisionProc)
        {
            DWORD dwStorePages = 0;
            DWORD dwRamPages = 0; 
            DWORD dwPageSize = 0; 
            BOOL bRet = (*GetSystemMemoryDivisionProc)(&dwStorePages,&dwRamPages,&dwPageSize);
            if(bRet)
            {
                int nPageCount = nSize/dwPageSize;
                if(nSize%dwPageSize != 0)
                {
                    nPageCount++;
                }
                (*SetSystemMemoryDivisionProc)(nPageCount);
            }
        }
        SetSystemMemoryDivisionProc = NULL;
        GetSystemMemoryDivisionProc = NULL;
        FreeLibrary(hDll);
        hDll = NULL;  
    }
#endif
}

 

标签:hDll,存储,dwPageSize,GetSystemMemoryDivisionProc,SetSystemMemoryDivisionProc,内存,Wi
来源: https://blog.51cto.com/u_15298588/3034241