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
}