1 #include <Windows.h> 2 #include "resource.h" 3 #include <strsafe.h> 4 5 6 PTSTR BigNumToString(LONG lNum, PTSTR szBuf, DWORD chBufSize) 7 { 8 TCHAR szNum[100]; 9 StringCchPrintf(szNum,_countof(szNum),TEXT("%d"),lNum); 10 11 NUMBERFMT nf; 12 nf.NumDigits = 0; 13 nf.LeadingZero = FALSE; 14 nf.Grouping = 3; 15 nf.lpDecimalSep = TEXT("."); 16 nf.lpThousandSep = TEXT(","); 17 nf.NegativeOrder = 0; 18 GetNumberFormat(LOCALE_USER_DEFAULT,0,szNum,&nf,szBuf,chBufSize); 19 20 return szBuf; 21 } 22 23 INT_PTR CALLBACK MainDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 24 { 25 BOOL bRet = TRUE; 26 27 switch(uMsg) 28 { 29 case WM_INITDIALOG: 30 31 SYSTEM_INFO sinf; 32 GetSystemInfo(&sinf); 33 34 TCHAR szBuf[50]; 35 36 SetDlgItemText(hDlg,IDC_PAGESIZE,BigNumToString(sinf.dwPageSize,szBuf,_countof(szBuf))); 37 38 StringCchPrintf(szBuf,_countof(szBuf),TEXT("%p"),sinf.lpMinimumApplicationAddress); 39 SetDlgItemText(hDlg,IDC_MINAPPADDR,szBuf); 40 StringCchPrintf(szBuf,_countof(szBuf),TEXT("%p"),sinf.lpMaximumApplicationAddress); 41 SetDlgItemText(hDlg,IDC_MAXAPPADDR,szBuf); 42 43 SetDlgItemText(hDlg,IDC_ALLOCGRAN,BigNumToString(sinf.dwAllocationGranularity,szBuf,_countof(szBuf))); 44 45 break; 46 case WM_CLOSE: 47 EndDialog(hDlg,0); 48 break; 49 default: 50 bRet = FALSE; 51 break; 52 } 53 54 return bRet; 55 } 56 57 int APIENTRY wWinMain(HINSTANCE hInstance, 58 HINSTANCE hPrevInstance, 59 LPTSTR lpCmdLine, 60 int nCmdShow) 61 { 62 DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAIN),NULL,MainDlgProc); 63 return 0; 64 }
时间: 2024-10-10 23:34:36