www.pudn.com > Clean.rar > SystemInfoDlg.cpp
// SystemInfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Clean.h"
#include "SystemInfoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSystemInfoDlg dialog
CSystemInfoDlg::CSystemInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSystemInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSystemInfoDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CSystemInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSystemInfoDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSystemInfoDlg, CDialog)
//{{AFX_MSG_MAP(CSystemInfoDlg)
ON_WM_TIMER()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSystemInfoDlg message handlers
BOOL CSystemInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
SetTimer(1, 500, NULL);
GetInfo();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSystemInfoDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(nIDEvent==1)
{
MEMORYSTATUS ms;
GlobalMemoryStatus(&ms);
CString str;
str.Format("%d K", ms.dwAvailPhys/1024);
SetDlgItemText(IDC_STATIC_FREEMEM, str);
SYSTEMTIME st;
GetLocalTime(&st);
str.Format("%d:%d:%d", st.wHour, st.wMinute,st.wSecond);
SetDlgItemText(IDC_STATIC_TIME, str);
}
CDialog::OnTimer(nIDEvent);
}
void CSystemInfoDlg::GetInfo()
{
//获取提示信息
TCHAR szName[255] = {_T('\0')};
DWORD dwLength =255;
DWORD dwLen =255;
DWORD dwSize = 0;
WORD MyYear, MyMonth, MyDay;
SYSTEMTIME CurrentTime;
MEMORYSTATUS MyMem;
OSVERSIONINFO info;
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if(GetComputerName(szName, &dwLen))
SetDlgItemText(IDC_STATIC_NAME, szName);
if(GetUserName(szName, &dwLength))
SetDlgItemText(IDC_STATIC_USER, szName);
GetSystemTime(&CurrentTime);
MyYear = CurrentTime.wYear;
MyMonth = CurrentTime.wMonth;
MyDay = CurrentTime.wDay;
wsprintf(szName, "%d年%d月%d日", MyYear, MyMonth,MyDay);
SetDlgItemText(IDC_STATIC_DATE, szName);
GlobalMemoryStatus(&MyMem);
dwSize = MyMem.dwTotalPhys;
wsprintf(szName, "%d bytes", dwSize);
SetDlgItemText(IDC_STATIC_MEM, szName);
DWORD dwID = 0;
if(GetVersionEx(&info))
{
dwID = info.dwPlatformId;
switch(dwID)
{
case VER_PLATFORM_WIN32s:
lstrcpy(szName, "Windows 3.x");
break;
case VER_PLATFORM_WIN32_WINDOWS:
lstrcpy(szName, "Windows 9.x");
break;
case VER_PLATFORM_WIN32_NT:
lstrcpy(szName, "Win2000/NT/XP");
break;
}
SetDlgItemText(IDC_STATIC_SYS, szName);
}
MEMORYSTATUS ms;
GlobalMemoryStatus(&ms);
CString str;
str.Format("%d K", ms.dwAvailPhys/1024);
SetDlgItemText(IDC_STATIC_FREEMEM, str);
SYSTEMTIME st;
GetLocalTime(&st);
str.Format("%d:%d:%d", st.wHour, st.wMinute,st.wSecond);
SetDlgItemText(IDC_STATIC_TIME, str);
}
void CSystemInfoDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
KillTimer(1);
}