Windows Memory - Memeory View 一个动态显示内存使用的SDK
2007-04-28 15:33
561 查看
// MemViewSDK.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "MemViewSDK.h"
#include "resource.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
HWND mainForm; // Main Window Handle
TCHAR szInfor[] =TEXT("Phicical Memory %lu bytes/nFree Physical Memory %lu bytes/nVirtual Memory %lu bytes/nFree Vitual Memory %lu bytes/nMemeory Usage%lu /nUser Mode Space %lu bytes/nUser Mode Space FREE %lu bytes/n");
BOOL CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void GetMemInfor()
{
MEMORYSTATUS stMemInfor;
TCHAR szBuffer[1024];
::GlobalMemoryStatus(&stMemInfor);
wsprintf(szBuffer, szInfor, stMemInfor.dwTotalPhys, stMemInfor.dwAvailPhys,/
stMemInfor.dwTotalPageFile, stMemInfor.dwAvailPageFile,/
stMemInfor.dwMemoryLoad, stMemInfor.dwTotalVirtual,
stMemInfor.dwAvailVirtual);
::SetDlgItemText(mainForm,IDC_INFO, szBuffer);
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
// First Fill Our Global Instance.
hInst = hInstance;
::DialogBoxParam(hInstance, (LPCWSTR)IDD_MainDlg, NULL,WndProc, NULL);
::ExitProcess(0);
return 1;
}
BOOL CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hIcon;
switch (message)
{
case WM_INITDIALOG:
mainForm =hWnd;
hIcon = (HWND)::LoadIcon(hInst, NULL);
if (hIcon)
{
::SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) (HICON)hIcon);
}
GetMemInfor();
SetTimer(hWnd,1,1000,NULL);
break;
case WM_CLOSE:
KillTimer(hWnd,1);
::EndDialog(hWnd, NULL);
break;
case WM_COMMAND:
::EndDialog(hWnd, NULL);
break;
case WM_TIMER:
::GetMemInfor();
default:
return FALSE;
}
//::InvalidateRect(hWnd, NULL, TRUE);
return TRUE;
}
//
#include "stdafx.h"
#include "MemViewSDK.h"
#include "resource.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
HWND mainForm; // Main Window Handle
TCHAR szInfor[] =TEXT("Phicical Memory %lu bytes/nFree Physical Memory %lu bytes/nVirtual Memory %lu bytes/nFree Vitual Memory %lu bytes/nMemeory Usage%lu /nUser Mode Space %lu bytes/nUser Mode Space FREE %lu bytes/n");
BOOL CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void GetMemInfor()
{
MEMORYSTATUS stMemInfor;
TCHAR szBuffer[1024];
::GlobalMemoryStatus(&stMemInfor);
wsprintf(szBuffer, szInfor, stMemInfor.dwTotalPhys, stMemInfor.dwAvailPhys,/
stMemInfor.dwTotalPageFile, stMemInfor.dwAvailPageFile,/
stMemInfor.dwMemoryLoad, stMemInfor.dwTotalVirtual,
stMemInfor.dwAvailVirtual);
::SetDlgItemText(mainForm,IDC_INFO, szBuffer);
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
// First Fill Our Global Instance.
hInst = hInstance;
::DialogBoxParam(hInstance, (LPCWSTR)IDD_MainDlg, NULL,WndProc, NULL);
::ExitProcess(0);
return 1;
}
BOOL CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hIcon;
switch (message)
{
case WM_INITDIALOG:
mainForm =hWnd;
hIcon = (HWND)::LoadIcon(hInst, NULL);
if (hIcon)
{
::SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) (HICON)hIcon);
}
GetMemInfor();
SetTimer(hWnd,1,1000,NULL);
break;
case WM_CLOSE:
KillTimer(hWnd,1);
::EndDialog(hWnd, NULL);
break;
case WM_COMMAND:
::EndDialog(hWnd, NULL);
break;
case WM_TIMER:
::GetMemInfor();
default:
return FALSE;
}
//::InvalidateRect(hWnd, NULL, TRUE);
return TRUE;
}
相关文章推荐
- 编写一个函数,此函数使用动态存储分配来产生一个字符串的副本。例如函数为strclone,则调用p=strclone(str),将会为一个新的字符串分配和str占内存大小相同的一个字符串,并将字符串st
- [cocos2dx笔记013]一个使用CCRenderTexture创建动态纹理显示数字的类
- Unity中uniwebview+EasyAR SDK显示一个透明网页使用总结
- C++[类设计] 一个使用new动态内存分配的集合类
- 给Swing程序添加一个动态显示内存情况的状态条
- Foxit Mobile PDF SDK 入门级(1)-显示一个PDF-Swift工程中的使用(Xcode 7.x, swift 2.x)
- [cocos2dx笔记013]一个使用CCRenderTexture创建动态纹理显示数字的类
- 请教一下:Windows任务管理器中显示的进程占用的内存是什么内存? 分配的还是使用的? 另外,最小化一个进程的时候为什么其占用的内存会大大降低?谢谢
- 动态和静态查看一个进程的内存使用
- 一个页面实现修改删除列表显示,ajax动态生成table(使用ajax,springmvc,jsp)
- 动态内存可跨函数使用
- Eclipse状态栏显示JVM内存使用情况的改进
- SharePoint2010:使用通知和状态栏区域动态显示信息
- 关于一个ListView使用多个item布局在优化时出现显示错乱的解决方案
- dskinlite(uieasy mfc界面库)使用记录3:绘制动态元素(按钮控件通过隐藏方式修改图片显示)
- C++--如何实现SDI程序使用CSplitterWnd创建的多个视图的动态地显示和关闭视图
- 刚才访问一个站点,竟然显示"站点超过cpu使用额度"
- Unity3d NGUI的使用(十二)(UIGrid动态列表显示)
- JavaWeb---使用JavaBean动态显示留言
- 动态加载的同一个Label的同一行字体显示不同的颜色