void CSysinfoDlg::OnRefresh()
{
// TODO: Add your control notification handler code here
// Variables used for getting the computer name
TCHAR szBuffer[256];
DWORD dwSize = 256;
// Retrieve the computer name for Windows
GetComputerName(szBuffer, &dwSize);
// Transfer the computer name to the appropriate
// member variable
m_strComputerName = szBuffer;
// Allocate structure to recieve memory status
MEMORYSTATUS mem_stat;
// Retrieve the current memory status
GlobalMemoryStatus(&mem_stat);
;
// Transfer the current memory details to the appropriate
// member variable
m_strTotalMemory.Format("%ld KB", mem_stat.dwTotalPhys / 1024);
m_strFreeMemory.Format("%ld KB", mem_stat.dwAvailPhys / 1024);
m_strMemoryLoad.Format("%d%%", mem_stat.dwMemoryLoad);
m_strTotalVitual.Format("%d KB", mem_stat.dwTotalVirtual / 1024);
m_strFreeVitual.Format("%d KB", mem_stat.dwAvailVirtual / 1024);
// Get the OS version of this computer
OSVERSIONINFO osvi;
//CString winver,os;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
switch(osvi.dwPlatformId)
{
case 0:
m_strOSVersion = "Win3.x";
break;
case 1:
m_strOSVersion = "Win95/98/Me";
break;
case 2:
m_strOSVersion = "WinNT/2000/XP";
break;
}
// Get the systeminfo
SYSTEM_INFO SystemInfo;
GetSystemInfo(&SystemInfo);
switch(SystemInfo.dwProcessorType)
{
case PROCESSOR_INTEL_386: m_strCpuInfo = "80386";break;
case PROCESSOR_INTEL_486: m_strCpuInfo = "80486";break;
case PROCESSOR_INTEL_PENTIUM: m_strCpuInfo = "Pentium";break;
}
// Get the disk free space
// LPCTSTR lpRootPathName; // root path
DWORD lpSectorsPerCluster; // sectors per cluster
DWORD lpBytesPerSector; // bytes per sector
DWORD lpNumberOfFreeClusters; // free clusters
DWORD lpTotalNumberOfClusters; // total clusters
DWORD lpFreeDiskSpace;
DWORD lpTotalDiskSpace;
GetDiskFreeSpace("C:", &lpSectorsPerCluster, &lpBytesPerSector, &lpNumberOfFreeClusters, &lpTotalNumberOfClusters);
// m_strFreeDiskSpace
lpTotalDiskSpace = lpSectorsPerCluster * lpBytesPerSector * lpTotalNumberOfClusters / 1024 / 1024;
lpFreeDiskSpace = lpSectorsPerCluster * lpBytesPerSector * lpNumberOfFreeClusters / 1024 / 1024;
m_strFreeDiskSpace.Format("C:%d MB", lpFreeDiskSpace);
m_strTotalDiskSpace.Format("C:%d MB", lpTotalDiskSpace);
// Get the screen pix
HDC m_hdcScreen;
m_hdcScreen=::GetDC(NULL);
int m_nHorzres = GetDeviceCaps(m_hdcScreen, HORZRES);
int m_nVertres = GetDeviceCaps(m_hdcScreen, VERTRES);
int m_nBitsPixel = GetDeviceCaps(m_hdcScreen, BITSPIXEL);
m_strScreenPix.Format("%d*%d / %dBP", m_nHorzres, m_nVertres, m_nBitsPixel);
// Get the version of IE
PUCHAR bufdata =new UCHAR[1024];
DWORD buflen = 1024;
ULONG type = REG_MULTI_SZ;
HKEY hKey = HKEY_LOCAL_MACHINE;
RegOpenKeyEx(hKey, "SOFTWARE\\Microsoft\\Internet Explorer", 0, KEY_READ, &hKey);
RegQueryValueEx(hKey, "Version", 0, &type, bufdata, &buflen);
m_strIeVersion = bufdata;
// Update the contents of controls to display
UpdateData(FALSE);
}
void CSysinfoDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CSysinfoDlg::OnAbouta()
{
// TODO: Add your control notification handler code here
::MessageBox(NULL, "This Program Based On Capter 5 of <<Visual C++ 6 Proactical>> \n\nRebuilded By DYH1919 \n\n2007.3.22-2007.3.26", "About", MB_OK|MB_ICONQUESTION);
}
// GetURL
void CSysinfoDlg::OnUrlGet()
{
ShellExecute(this->m_hWnd,"open","
http://www.blon.cn/ ",NULL,"c:\\",SW_SHOW);
}
// Update
void CSysinfoDlg::OnUpdate()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_VER)->SetWindowText("检查是否有新版本…");
HRESULT ret = U
RLDownloadToFile(NULL,"
http://www.blon.cn/systeminfo/update/version.txt","c:\\version.ini",0,NULL);
if(ret == S_OK) //如果下载成功
{
// 读取Version 段的数据,得到新版本好
int newversion = GetPrivateProfileInt("Version","Version",10,"c:\\version.ini");
if (newversion > 10) //跟当前版本比较,10表示目前版本V1.0 ,根据具体版本自己设置
{
GetDlgItem(IDC_VER)->SetWindowText("有新版提供下载,现在开始下载.");
// GetPrivateProfileString("URL","URL",0,"
http://www.blon.cn/systeminfo/systeminfo.exe ",100,"c:\\version.ini");
HINSTANCE returnvalue = ShellExecute(this->m_hWnd,"open","
http://www.blon.cn/systeminfo/update/SystemManager.exe ",NULL,"c:\\",SW_SHOW);
if(returnvalue == 0)
{
GetDlgItem(IDC_VER)->SetWindowText("下载完毕,请用此程序覆盖原文件即可.");
}
else
GetDlgItem(IDC_VER)->SetWindowText("对不起,暂时不能下载,请稍后再试.");
}
else
GetDlgItem(IDC_VER)->SetWindowText("对不起,暂时没有新版本提供下载.");
DeleteFile("c:\\version.ini"); // 用完后删除
}
else
GetDlgItem(IDC_VER)->SetWindowText("网络连接失败.");
}
void CSysinfoDlg::OnRul()
{
// TODO: Add your control notification handler code here
ShellExecute(this->m_hWnd,"open","
http://www.blon.cn/ ",NULL,NULL,SW_SHOW);
}