系统信息
This commit is contained in:
@@ -0,0 +1,165 @@
|
|||||||
|
#include "c_WinApp.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||||
|
/* */
|
||||||
|
|
||||||
|
#define WINDOW_CLASS_NAME "SysInfo.Main"
|
||||||
|
|
||||||
|
#define KB 1024
|
||||||
|
#define MB ((size_t)((size_t)KB*1024))
|
||||||
|
#define GB ((size_t)((size_t)MB*1024))
|
||||||
|
#define TB ((size_t)((size_t)GB*1024))
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||||
|
/* */
|
||||||
|
|
||||||
|
static HWND EditWin;
|
||||||
|
|
||||||
|
static LPSTR GetSysInfo(LPSTR s) {
|
||||||
|
SYSTEM_INFO SystemInfo;
|
||||||
|
MEMORYSTATUS MStatus;
|
||||||
|
char Temp1[500];
|
||||||
|
char Temp2[500];
|
||||||
|
char CR[3]={13, 10, 0};
|
||||||
|
GetSystemInfo(&SystemInfo);
|
||||||
|
snprintf(Temp1, sizeof(Temp1), "%sOEM ID:%ld %s"
|
||||||
|
"Page Size %ld %s"
|
||||||
|
"MinAppAddress: %"PRIu64" %s"
|
||||||
|
"MaxAppAddress: %"PRIu64" %s"
|
||||||
|
"Active Processor Mask: %"PRIX64" %s"
|
||||||
|
"Number of Processors: %ld %s"
|
||||||
|
"Processor Type: %ld %s"
|
||||||
|
"Allocation Granularity: %ld %s %s",
|
||||||
|
CR, SystemInfo.dwOemId, CR,
|
||||||
|
SystemInfo.dwPageSize, CR,
|
||||||
|
SystemInfo.lpMinimumApplicationAddress, CR,
|
||||||
|
SystemInfo.lpMaximumApplicationAddress, CR,
|
||||||
|
SystemInfo.dwActiveProcessorMask, CR,
|
||||||
|
SystemInfo.dwNumberOfProcessors, CR,
|
||||||
|
SystemInfo.dwProcessorType, CR,
|
||||||
|
SystemInfo.dwAllocationGranularity, CR, CR
|
||||||
|
);
|
||||||
|
MStatus.dwLength = sizeof(MStatus);
|
||||||
|
GlobalMemoryStatus(&MStatus);
|
||||||
|
snprintf(Temp2, sizeof(Temp2), "%sMemory Load: %ld %s"
|
||||||
|
"Total Physical: %"PRIu64"GB %s"
|
||||||
|
"Available Physical: %"PRIu64"GB %s"
|
||||||
|
"Total Page File: %"PRIu64" %s"
|
||||||
|
"Available Page File: %"PRIu64" %s"
|
||||||
|
"Total Virtual: %"PRIu64"TB %s"
|
||||||
|
"Available Virtual: %"PRIu64"TB",
|
||||||
|
CR, MStatus.dwMemoryLoad, CR,
|
||||||
|
MStatus.dwTotalPhys/GB, CR,
|
||||||
|
MStatus.dwAvailPhys/GB, CR,
|
||||||
|
MStatus.dwTotalPageFile, CR,
|
||||||
|
MStatus.dwAvailPageFile, CR,
|
||||||
|
MStatus.dwTotalVirtual/TB, CR,
|
||||||
|
MStatus.dwAvailVirtual/TB
|
||||||
|
);
|
||||||
|
strcpy(s, "SYSTEM INFO");
|
||||||
|
strcat(s, Temp1);
|
||||||
|
strcat(s, "MEMORY STATUS");
|
||||||
|
strcat(s, Temp2);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||||
|
/* */
|
||||||
|
|
||||||
|
|
||||||
|
c_WinGUI_EventHandlerDef(WM_DESTROY, Main_Destroy) {
|
||||||
|
PostQuitMessage(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
c_WinGUI_EventHandlerDef(WM_CREATE, Main_Create) {
|
||||||
|
char s[1000];
|
||||||
|
EditWin = CreateWindow("edit", "Original Text",
|
||||||
|
WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|ES_READONLY|ES_LEFT|ES_AUTOVSCROLL|ES_MULTILINE,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
hwnd, (HMENU)0, lpCreateStruct->hInstance, NULL);
|
||||||
|
GetSysInfo(s);
|
||||||
|
SetWindowText(EditWin, s);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
c_WinGUI_EventHandlerDef(WM_SIZE, Main_Size) {
|
||||||
|
if (EditWin) {
|
||||||
|
SetWindowPos(EditWin, NULL, 0, 0, cx, cy, SWP_NOZORDER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c_WinGUI_EventMapBegin(WndProc)
|
||||||
|
c_WinGUI_EventMap(WM_DESTROY, Main_Destroy);
|
||||||
|
c_WinGUI_EventMap(WM_CREATE, Main_Create);
|
||||||
|
c_WinGUI_EventMap(WM_SIZE, Main_Size);
|
||||||
|
c_WinGUI_EventMapEnd()
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
BOOL Register(HINSTANCE hInstance) {
|
||||||
|
WNDCLASS WndClass;
|
||||||
|
WndClass.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
WndClass.lpfnWndProc = WndProc;
|
||||||
|
WndClass.cbClsExtra = 0;
|
||||||
|
WndClass.cbWndExtra = 0;
|
||||||
|
WndClass.hInstance = hInstance;
|
||||||
|
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||||
|
WndClass.lpszMenuName = NULL;
|
||||||
|
WndClass.lpszClassName = WINDOW_CLASS_NAME;
|
||||||
|
return RegisterClass(&WndClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
HWND Create(HINSTANCE hInstance, int nCmdShow) {
|
||||||
|
HWND hwnd = CreateWindow(WINDOW_CLASS_NAME, WINDOW_CLASS_NAME,
|
||||||
|
WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
|
NULL, NULL, hInstance, NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hwnd == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow(hwnd, nCmdShow);
|
||||||
|
UpdateWindow(hwnd);
|
||||||
|
return hwnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||||
|
/* */
|
||||||
|
|
||||||
|
c_WinGUI_Main(){
|
||||||
|
MSG msg;
|
||||||
|
|
||||||
|
if (!hPrevInstance) {
|
||||||
|
if (!Register(hInstance)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WinApp.hInstance = hInstance;
|
||||||
|
|
||||||
|
|
||||||
|
HWND MainHwnd = Create(hInstance, nShowCmd);
|
||||||
|
if (!MainHwnd) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
WinApp.hwnd = MainHwnd;
|
||||||
|
|
||||||
|
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (int)msg.wParam;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -58,12 +58,13 @@ static void ArrangeWinds(HWND hwnd) {
|
|||||||
}else {
|
}else {
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
GetWindowRect(hwnd, &R);
|
GetWindowRect(hwnd, &R);
|
||||||
MoveWindow(ChildWindows[i], R.left + 10 + GetSystemMetrics(SM_CXFRAME) + (j*100),
|
MoveWindow(ChildWindows[i],
|
||||||
|
R.left + 10 + GetSystemMetrics(SM_CXFRAME) + (j*100),
|
||||||
R.top + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYMENU) + 10,
|
R.top + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYMENU) + 10,
|
||||||
100, 100, TRUE);
|
100, 100, TRUE);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void HandleBrush(HWND hwnd, int id) {
|
static void HandleBrush(HWND hwnd, int id) {
|
||||||
HBRUSH OldBrush;
|
HBRUSH OldBrush;
|
||||||
|
|||||||
Reference in New Issue
Block a user