??Windows????????С???ó????е????????
???????????? ???????[ 2013/1/8 15:51:37 ] ????????
?????????
???????????????????????????е??????????????????С?????????????GetSystemInfo?????????????й?????
VOID GetSystemInfo(LPSYSTEM_INFO psi);
SYSTEM_INFO?????????£?
typedef struct _SYSTEM_INFO{
union{
struct {
WORD wProcessorArchitecture;
WORD wReserved;
};
};
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;
LPVOLID lpMaximumApplicationAddress;
DWORD_PTR dwActiveProcessorMask;
DWORD dwNumberOfProcessor;
DWORD dwProcessorType;
DWORD dwAllocationGranularity;
WORD wProcessorLevel;
WORD wProcessorRevision;
}SYSTEM_INFO??*LPSYSTEM_INFO;
???????????????????????????й??
????dwPageSize???cpu????С??x86??x64?????У?????4K??
????lpMinimumApplicationAddress?????????п????????С????????????????????????儷???64K??????????????64K??
????lpMaximumApplicationAddress?????????????е??????д??
???????????????
????dwAllocationGranularity????????????????????????????
???????????????????????
????wReserved?????????????????á?
????dwNumOfProcessor????cpu????????
????dwActiveProcessorMaskλ?????????????Щcpu?????????????????????????
????dwProcessorType??????????????á?
????wProcessorArchitecture????????????????????x86??x64;
????wProcessorLevel??????????????????????????Intel????2????4.
????wProcessorRevision???????wProcessLevel????????
????//???′???????????????漰???????????????????á?
#include"windows.h"
#include<iostream>
#include"tchar.h"
TCHAR TextData[]=TEXT("c:Usersyangyangdocumentsvisual studio 2010ProjectsMEM_RESETMEM_RESETmain.cppc:Usersyangyangdocumentsvisual studio 2010ProjectsMEM_RESETMEM_RESETmain.cpp");
int main(int argc??char**argv)
{
PTSTR pszData=(PTSTR)VirtualAlloc(NULL??1024??MEM_RESERVE|MEM_COMMIT??PAGE_READWRITE);
if(pszData==NULL)
{
MessageBox(NULL??TEXT("???????")??TEXT("")??MB_OK);
}
_tcscpy_s(pszData??1024??TextData);
int ret=MessageBox(NULL??TEXT("???????????????棿")??TEXT("")??MB_YESNO);
if(ret==IDNO)
{
MEMORY_BASIC_INFORMATION mbi;
VirtualQuery(pszData??&mbi??sizeof(mbi));
VirtualAlloc(pszData??mbi.RegionSize??MEM_RESET??PAGE_READWRITE);
}
MEMORYSTATUS mst;
GlobalMemoryStatus(&mst);
PVOID pvAddress=VirtualAlloc(NULL??mst.dwAvailVirtual??MEM_RESERVE|MEM_COMMIT??PAGE_READWRITE);
if(pvAddress)
{
ZeroMemory(pvAddress??mst.dwAvailVirtual);
}
if(!_tcscmp(TextData??pszData))
{
MessageBox(NULL??TEXT("??????棡")??TEXT("")??MB_YESNO);
}
else
{
MessageBox(NULL??TEXT("δ???棡")??TEXT("")??MB_YESNO);
}
getchar();
VirtualFree(pvAddress??0??MEM_RELEASE);
VirtualFree(pszData??0??MEM_RELEASE);
return 0;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11