About.cpp
资源名称:p2p_vod.rar [点击查看]
上传用户:liguizhu
上传日期:2015-11-01
资源大小:2422k
文件大小:3k
源码类别:
P2P编程
开发平台:
Visual C++
- /*
- * Openmysee
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
- #include "stdafx.h"
- #include ".about.h"
- #include "resource.h"
- #include "MultiLanguageMgr.h"
- #pragma message("automatic link to Version.lib")
- #pragma comment(lib, "Version.lib")
- extern volatile HINSTANCE g_hInstance;
- LRESULT CALLBACK CAbout::_AboutWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message)
- {
- case WM_INITDIALOG:
- {
- //set about dialog title
- MultiLanguage LanguageDll;
- SetWindowText(hDlg, LanguageDll.GetStringByStr(_T("关于OpenMySee")));
- //set about dialog content
- HWND hTitle = GetDlgItem(hDlg, IDC_ABOUTSTR);
- if(hTitle != NULL)
- {
- CString str(LanguageDll.GetStringByStr(_T("OpenMysee 版权所有")));
- str += _T("n");
- DWORD prgver[2], filever[2];
- if(GetPrgVer(g_hInstance, prgver, filever))
- {
- str += LanguageDll.GetStringByStr(_T("版本:"));
- TCHAR buf[10];
- if(HIWORD(prgver[1]) == 0)
- _stprintf(buf, _T("%d.%d"), (int) (HIWORD(prgver[0])), (int) (LOWORD(prgver[0])));
- else
- _stprintf(buf, _T("%d.%d.%d"), (int) (HIWORD(prgver[0])), (int) (LOWORD(prgver[0])),
- (int) (HIWORD(prgver[1])));
- str += buf;
- }
- SetWindowText(hTitle, str);
- HWND hdesktop = GetDesktopWindow();
- if(hdesktop)
- {
- RECT desktoprect, rect;
- GetWindowRect(hdesktop, &desktoprect);
- GetWindowRect(hDlg, &rect);
- POINT point;
- point.x = (desktoprect.right - desktoprect.left)/2 - (rect.right - rect.left)/2;
- point.y = (desktoprect.bottom - desktoprect.top)/2 - (rect.bottom - rect.top)/2;
- SetWindowPos(hDlg, NULL, point.x, point.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- }
- }
- }
- return TRUE;
- case WM_COMMAND:
- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hDlg, LOWORD(wParam));
- return TRUE;
- }
- break;
- }
- return FALSE;
- }
- CAbout::CAbout()
- {
- DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), NULL, (DLGPROC)_AboutWndProc);
- }
- CAbout::~CAbout(void)
- {
- }
- BOOL CAbout::GetPrgVer(HINSTANCE h_module, DWORD prgver[2], DWORD filever[2])
- {
- TCHAR lpszFileName[MAX_PATH];
- if(GetModuleFileName(h_module, lpszFileName, MAX_PATH) == 0)
- return FALSE;
- DWORD size = GetFileVersionInfoSize(lpszFileName, 0);
- BYTE* pBuffer = new BYTE[size];
- GetFileVersionInfo(lpszFileName, 0, size, pBuffer);
- VS_FIXEDFILEINFO* p_Info = NULL;
- UINT length;
- VerQueryValue(pBuffer, _T("\"), (LPVOID*) &p_Info, &length);
- if(p_Info)
- {
- prgver[0] = p_Info->dwProductVersionMS;
- prgver[1] = p_Info->dwProductVersionLS;
- filever[0] = p_Info->dwFileVersionMS;
- filever[1] = p_Info->dwFileVersionLS;
- delete[] pBuffer;
- return TRUE;
- }
- else
- {
- delete[] pBuffer;
- return FALSE;
- }
- }