程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> win32系統信息獲取,win32系統信息

win32系統信息獲取,win32系統信息

編輯:C++入門知識

win32系統信息獲取,win32系統信息


 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 }

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved