• 内存使用监视器[对话框]


    #include <windows.h>
    #include "resource.h"
    #define  IDT_TIMER 3000
    BOOL __stdcall DlgProc(HWND, UINT, WPARAM, LPARAM);
    
    int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
    {
        int nResult = ::DialogBoxParam(
            hInstance,        // 实例句柄
            (LPCTSTR)IDD_MAIN,    // 对话框资源ID号
            NULL,            // 父窗口句柄
            DlgProc,        // 消息处理函数
            NULL);             // 对话框初始化的值,在WM_INITDIALOG消息的lParam参数中取出
        return 0;
    }
    
    BOOL __stdcall DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch(message)
        {    
        case WM_INITDIALOG: // 初始化对话框
            ::SetTimer(hDlg, IDT_TIMER, 500, NULL);
            break;
        case WM_TIMER:
            char sz[5][32];
            MEMORYSTATUS ms;
            // 取得内存状态信息
            ::GlobalMemoryStatus(&ms);
            wsprintf(sz[0], "%-5d MB", ms.dwTotalPhys/(1024*1024));
            ::SetWindowText(::GetDlgItem(hDlg, IDC_STATIC1), sz[0]);
            wsprintf(sz[1], "%-5d MB", ms.dwAvailPhys/(1024*1024));
            ::SetWindowText(::GetDlgItem(hDlg, IDC_STATIC2), sz[1]);
            wsprintf(sz[2], "%-5d MB", ms.dwTotalVirtual/(1024*1024));
             ::SetWindowText(::GetDlgItem(hDlg, IDC_STATIC3), sz[2]);
            wsprintf(sz[3], "%-5d MB", ms.dwAvailVirtual/(1024*1024));
            ::SetWindowText(::GetDlgItem(hDlg, IDC_STATIC4), sz[3]);
            wsprintf(sz[4], "%d%%", ms.dwMemoryLoad);
            ::SetWindowText(::GetDlgItem(hDlg, IDC_STATIC5), sz[4]);
            break;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
            case IDCANCEL:
                ::EndDialog (hDlg, IDCANCEL);
                break;
            }
            break;
        }
        return 0;
    }
  • 相关阅读:
    This is a thoughtful essay
    MSSQL 模糊搜索全文(过程、函数、触发器等)
    MSSQL 高并发下生成连续不重复的订单号
    MSSQL sql numeric转字符串显示不补0
    iOS 开发之UIStackView的应用
    Java day 5
    Java day 4
    Java day 3-1
    Java day 3
    Java day 2
  • 原文地址:https://www.cnblogs.com/qiangua/p/3000551.html
Copyright © 2020-2023  润新知