Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.8 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. //
  3. // AboutDlg.cpp
  4. //
  5. // 1998 Jun, Hiro Yamamoto
  6. //
  7. #include "stdafx.h"
  8. #include "custcon.h"
  9. #include "AboutDlg.h"
  10. #include <malloc.h>
  11. /////////////////////////////////////////////////////////////////////////////
  12. // �A�v���P�[�V�����̃o�[�W���������Ŏg�����Ă��� CAboutDlg �_�C�A���O
  13. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  14. {
  15. //{{AFX_DATA_INIT(CAboutDlg)
  16. //}}AFX_DATA_INIT
  17. }
  18. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  19. {
  20. CDialog::DoDataExchange(pDX);
  21. //{{AFX_DATA_MAP(CAboutDlg)
  22. //}}AFX_DATA_MAP
  23. }
  24. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  25. //{{AFX_MSG_MAP(CAboutDlg)
  26. //}}AFX_MSG_MAP
  27. END_MESSAGE_MAP()
  28. struct FullVersion {
  29. public:
  30. DWORD m_ms;
  31. DWORD m_ls;
  32. public:
  33. FullVersion(DWORD ms, DWORD ls) : m_ms(ms), m_ls(ls) { }
  34. };
  35. FullVersion GetVersionInfo()
  36. {
  37. TCHAR path[MAX_PATH];
  38. path[::GetModuleFileName(AfxGetInstanceHandle(), path, sizeof path / sizeof path[0])] = 0;
  39. DWORD dummy;
  40. DWORD size = GetFileVersionInfoSize(path, &dummy);
  41. ASSERT(size != 0); // 0 means error
  42. LPVOID lpData = alloca(size);
  43. ASSERT(lpData);
  44. VERIFY( GetFileVersionInfo(path, 0, size, lpData) );
  45. LPVOID lpBuffer = NULL;
  46. UINT vSize;
  47. VERIFY( VerQueryValue(lpData, _T("\\"), &lpBuffer, &vSize) );
  48. if (lpBuffer) {
  49. VS_FIXEDFILEINFO* info = (VS_FIXEDFILEINFO*)lpBuffer;
  50. return FullVersion(info->dwProductVersionMS, info->dwProductVersionLS);
  51. } else {
  52. return FullVersion(0, 0);
  53. }
  54. }
  55. BOOL CAboutDlg::OnInitDialog()
  56. {
  57. CDialog::OnInitDialog();
  58. FullVersion version = GetVersionInfo();
  59. CString format;
  60. format.LoadString(IDS_VERSION_TEMPLATE);
  61. CString buf;
  62. buf.Format(format, HIWORD(version.m_ms), LOWORD(version.m_ms), HIWORD(version.m_ls), LOWORD(version.m_ls));
  63. SetDlgItemText(IDC_MAIN_TITLE, buf);
  64. return TRUE;
  65. }