您的位置:首页 > 其它

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;
}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐