/* * Copyright 2004 Perforce Software. All rights reserved. * * Developed by Data Shades Ltd. */ #include "AboutDialog.h" #define BUFSIZE 80 AboutDialog::AboutDialog( PluginOperations *ops, TCHAR *name, TCHAR *pluginVer, TCHAR *appVer ) : Dialog( ops, IDD_ABOUT_DIALOG, DialogWndProc ) { pluginName = name; pluginVersion = pluginVer; appVersion = appVer; } bool AboutDialog::WindowsVersion( UniStrBuf &buff ) { OSVERSIONINFOEX osvi; BOOL bOsVersionInfoEx; TCHAR numStr[MAX_PATH]; // Try calling GetVersionEx using the OSVERSIONINFOEX structure. // If that fails, try using the OSVERSIONINFO structure. buff.Append( _T("Windows version: ") ); ZeroMemory( &osvi, sizeof( OSVERSIONINFOEX ) ); osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFOEX ); if ( !( bOsVersionInfoEx = GetVersionEx ( ( OSVERSIONINFO * ) &osvi ) ) ) { osvi.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO ); if (! GetVersionEx ( ( OSVERSIONINFO * ) &osvi ) ) { return false; } } switch ( osvi.dwPlatformId ) { // Test for the Windows NT product family. case VER_PLATFORM_WIN32_NT: { // Test for the specific product family. if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) { buff.Append( _T("Microsoft Windows Server 2003 family, ") ); } if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) { buff.Append( _T("Microsoft Windows XP ") ); } if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) { buff.Append( _T("Microsoft Windows 2000 ") ); } if ( osvi.dwMajorVersion <= 4 ) { buff.Append( _T("Microsoft Windows NT ") ); } if( bOsVersionInfoEx ) { // Test for the workstation type. /* if ( osvi.wProductType == VER_NT_WORKSTATION ) { if( osvi.dwMajorVersion == 4 ) { printf ( "Workstation 4.0 " ); } else if( osvi.wSuiteMask & VER_SUITE_PERSONAL ) { printf ( "Home Edition " ); } else { printf ( "Professional " ); } } // Test for the server type. else if ( osvi.wProductType == VER_NT_SERVER || osvi.wProductType == VER_NT_DOMAIN_CONTROLLER ) { if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) { if ( osvi.wSuiteMask & VER_SUITE_DATACENTER ) { printf ( "Datacenter Edition " ); } else if ( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) { printf ( "Enterprise Edition " ); } else if ( osvi.wSuiteMask == VER_SUITE_BLADE ) { printf ( "Web Edition " ); } else { printf ( "Standard Edition " ); } } else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) { if ( osvi.wSuiteMask & VER_SUITE_DATACENTER ) { printf ( "Datacenter Server " ); } else if ( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) { printf ( "Advanced Server " ); } else { printf ( "Server " ); } } else {// Windows NT 4.0 if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) { printf ("Server 4.0, Enterprise Edition " ); } else { printf ( "Server 4.0 " ); } } } */ } else { HKEY hKey; TCHAR szProductType[BUFSIZE]; DWORD dwBufLen = BUFSIZE; LONG lRet; lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Control\\ProductOptions"), 0, KEY_QUERY_VALUE, &hKey ); if ( lRet != ERROR_SUCCESS ) { return false; } lRet = RegQueryValueEx( hKey, _T("ProductType"), NULL, NULL, (LPBYTE) szProductType, &dwBufLen); if ( ( lRet != ERROR_SUCCESS ) || ( dwBufLen > BUFSIZE ) ) { return NULL; } RegCloseKey( hKey ); if ( lstrcmpi( _T("WINNT"), szProductType) == 0 ) { buff.Append( _T("Workstation ") ); } if ( lstrcmpi( _T("LANMANNT"), szProductType) == 0 ) { buff.Append( _T("Server ") ); } if ( lstrcmpi( _T("SERVERNT"), szProductType) == 0 ) { buff.Append( _T("Advanced Server ") ); } _stprintf_s( numStr, _T("%d"), osvi.dwMajorVersion ); buff.Append( numStr ); buff.Append( _T(".") ); _stprintf_s( numStr, _T("%d"), osvi.dwMinorVersion ); buff.Append( numStr ); buff.Append( _T(" ") ); } // Display service pack (if any) and build number. if ( osvi.dwMajorVersion == 4 && lstrcmpi( osvi.szCSDVersion, _T("Service Pack 6") ) == 0 ) { HKEY hKey; LONG lRet; // Test for SP6 versus SP6a. lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"), 0, KEY_QUERY_VALUE, &hKey ); if ( lRet == ERROR_SUCCESS ) { buff.Append( _T("Service Pack 6a (Build ") ); _stprintf_s( numStr, _T("%d"), (osvi.dwBuildNumber & 0xFFFF) ); buff.Append( numStr ); buff.Append( _T(")") ); } else { // Windows NT 4.0 prior to SP6a buff.Append( osvi.szCSDVersion ); buff.Append( _T(" (Build ") ); _stprintf_s( numStr, _T("%d"), (osvi.dwBuildNumber & 0xFFFF) ); buff.Append( numStr ); buff.Append( _T(")") ); } RegCloseKey( hKey ); } else {// Windows NT 3.51 and earlier or Windows 2000 and later buff.Append( osvi.szCSDVersion ); buff.Append( _T(" (Build ") ); _stprintf_s( numStr, _T("%d"), (osvi.dwBuildNumber & 0xFFFF) ); buff.Append( numStr ); buff.Append( _T(")") ); } } break; // Test for the Windows 95 product family. case VER_PLATFORM_WIN32_WINDOWS: if ( osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0 ) { buff.Append( _T("Microsoft Windows 95 ") ); if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' ) { buff.Append( _T("OSR2 ") ); } } if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) { buff.Append( _T("Microsoft Windows 98 ") ); if ( osvi.szCSDVersion[1] == 'A' ) { buff.Append( _T("SE ") ); } } if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) { buff.Append( _T("Microsoft Windows Millennium Edition") ); } break; case VER_PLATFORM_WIN32s: buff.Append( _T("Microsoft Win32s") ); break; } return true; } BOOL CALLBACK AboutDialog::DialogWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch(uMsg) { case WM_INITDIALOG: { AboutDialog *dialog = ( AboutDialog * )lParam; dialog->SaveDialogObject( hWnd, dialog ); UniStrBuf version; UniStrBuf pluginVersion; dialog->WindowsVersion( version ); SetDlgItemText( hWnd, IDC_PLUGIN_NAME_TEXT, dialog->PluginName() ); pluginVersion.Set( _T("Version: ") ); pluginVersion.Append( dialog->PluginVersion() ); pluginVersion.Append( _T(" (Beta)") ); SetDlgItemText( hWnd, IDC_PLUGIN_VERSION_TEXT, pluginVersion.Text() ); SetDlgItemText( hWnd, IDC_APP_VERSION_TEXT, dialog->AppVersion() ); SetDlgItemText( hWnd, IDC_WIN_VERSION_TEXT, version.Text() ); Centre( hWnd ); } break; case WM_COMMAND: switch ( LOWORD( wParam ) ) { case IDOK: EndDialog( hWnd, TRUE ); return true; case IDCANCEL: EndDialog( hWnd, FALSE ); return true; } } return false; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 11314 | Robert Cowham | Initial population of perforce_software version of P4OFC | ||
//guest/robert_cowham/perforce/P4OFC/main/libp4gt/AboutDialog.cpp | |||||
#1 | 10843 | Robert Cowham |
Initial version of P4OFC source code. See README.txt (and LICENSE.txt and doc\P4OFC-Design.docx) |