⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 about.c

📁 A arithmetical resolution about Hanoi tower . compiled by Visaul C++
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "StdSDK.h"
#include "about.h"
#include "resource.h"

static BOOL CALLBACK
aboutDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ;

// Function prototypes for message handlers
static BOOL aboutDlg_OnContextMenu (HWND hwnd, HWND hwndCtl, int xPos, 
                                                             int yPos) ;
static void aboutDlg_OnHelp (HWND hwnd, LPHELPINFO lphi) ;
static BOOL aboutDlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam) ;
static void aboutDlg_OnCommand (HWND hwnd, int id, HWND hwndCtl, 
                                                            UINT codeNotify) ;
//static int getNTVersion () ;
// Function prototypes for static functions

static void  displayExecutableVersionInfo (HWND hwnd) ;
static void  displayOperatingSystemVersionInfo (HWND hwnd) ;
static void  displayProcessorVersionInfo (HWND hwnd) ;

static DWORD formatMessageFromString (LPCTSTR Format, LPTSTR  Buffer, 
                                                          DWORD nSize, ...) ;
typedef enum { typeDefault        = 0,
               typeAdvancedServer = 1,
               typeWorkstation    = 2,
               typeServer         = 3 } NTTYPE ;


static BOOL CALLBACK
aboutDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
        case WM_CONTEXTMENU:           
            return HANDLE_WM_CONTEXTMENU (hwnd, wParam, lParam, aboutDlg_OnContextMenu) ;

        case WM_HELP:                  
            return HANDLE_WM_HELP (hwnd, wParam, lParam, aboutDlg_OnHelp) ;

        case WM_INITDIALOG:            
            return HANDLE_WM_INITDIALOG (hwnd, wParam, lParam, aboutDlg_OnInitDialog) ;

        case WM_COMMAND:               
            return HANDLE_WM_COMMAND (hwnd, wParam, lParam, aboutDlg_OnCommand) ;
    }
    return FALSE ;
}
//  Array of control identifiers and help context identifier pairs. 
#define IDH_ABOUT_FILEDESCRIPTION   IDC_ABOUT_FILEDESCRIPTION
#define IDH_ABOUT_VERSION           IDC_ABOUT_VERSION
#define IDH_ABOUT_LEGALCOPYRIGHT    IDC_ABOUT_LEGALCOPYRIGHT
#define IDH_ABOUT_COMMENTS          IDC_ABOUT_COMMENTS
#define IDH_ABOUT_OSVERSION         IDC_ABOUT_OSVERSION
#define IDH_ABOUT_PROCESSORVERSION  IDC_ABOUT_PROCESSORVERSION
#define IDH_ABOUT_LEGALTRADEMARKS   IDC_ABOUT_LEGALTRADEMARKS
 
static DWORD aContextIds [] = { 
    IDC_ABOUT_FILEDESCRIPTION,  IDH_ABOUT_FILEDESCRIPTION,
    IDC_ABOUT_VERSION,          IDH_ABOUT_VERSION,
    IDC_ABOUT_LEGALCOPYRIGHT,   IDH_ABOUT_LEGALCOPYRIGHT,
    IDC_ABOUT_COMMENTS,         IDH_ABOUT_COMMENTS,
    IDC_ABOUT_OSVERSION,        IDH_ABOUT_OSVERSION,
    IDC_ABOUT_PROCESSORVERSION, IDH_ABOUT_PROCESSORVERSION,
    IDC_ABOUT_LEGALTRADEMARKS,  IDH_ABOUT_LEGALTRADEMARKS,
    0,                          0
} ;
 
static BOOL
aboutDlg_OnContextMenu (HWND hwnd, HWND hwndCtl, int xPos, int yPos)
{    
    WinHelp (hwndCtl, getHelpFileName (), HELP_CONTEXTMENU, 
                                               (DWORD) (LPVOID) aContextIds) ;
    return TRUE ;
}

static void
aboutDlg_OnHelp (HWND hwnd, LPHELPINFO lphi)
{
    ASSERT (HELPINFO_WINDOW == lphi->iContextType) ;

    if (HELPINFO_WINDOW == lphi->iContextType) {    // Must be for a control!

        int             nID ;
        int             nIndex ;

        HWND hwndCtl = lphi->hItemHandle ;

        ASSERT (NULL != hwndCtl) ;
        ASSERT (IsWindow (hwndCtl)) ;

        nID = GetWindowID (hwndCtl) ;

        for (nIndex = 0 ; nIndex < DIM (aContextIds) - 2; nIndex += 2) {
            if (aContextIds [nIndex] == (DWORD) nID) {
                WinHelp (hwndCtl, getHelpFileName (), 
                         HELP_WM_HELP, (DWORD) (LPVOID) aContextIds) ;
                return ;
            }
        }
    }
}             

static BOOL
aboutDlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
    centerWindow (hwnd, NULL) ;
    displayExecutableVersionInfo (hwnd) ;
    displayOperatingSystemVersionInfo (hwnd) ;
    displayProcessorVersionInfo (hwnd) ;
    return TRUE ;
}

static const TCHAR ValueNameBase [] = TEXT("\\StringFileInfo\\040904B0\\") ;
static const TCHAR ProductName []   = TEXT("ProductName") ;
#define BASECHARS    (DIM(ValueNameBase) - 1)

static void
displayExecutableVersionInfo (HWND hwnd)
{
    BOOL      Result ;                
    DWORD     dwVerInfoSize ;         
    DWORD     dwHandle ;              
    HMODULE   hmod ;                  
    HWND      hwndControl ;           
    LPVOID    pVerInfo ;              
    LPVOID    pValue ;               
    TCHAR     FullPath [_MAX_PATH] ;
    TCHAR     ValueName [256] ; 
    UINT      uLength ; 

    hmod = GetModuleHandle (NULL) ;
    GetModuleFileName (hmod, FullPath, DIM(FullPath)) ;

    dwVerInfoSize = GetFileVersionInfoSize (FullPath, &dwHandle) ;
    if (0 == dwVerInfoSize)
        return ;
    pVerInfo = malloc (dwVerInfoSize) ;
    ASSERT (NULL != pVerInfo) ;
    if (NULL == pVerInfo)
        return ;
    VERIFY(GetFileVersionInfo (FullPath, dwHandle, dwVerInfoSize, pVerInfo)) ;
    _tcscpy (ValueName, ValueNameBase) ;
    _tcscpy (ValueName + BASECHARS, ProductName) ;
    Result = VerQueryValue (pVerInfo, ValueName, &pValue, &uLength) ;
    ASSERT (Result) ;

    GetWindowText (hwnd, ValueName, DIM (ValueName)) ;
    _tcscat (ValueName, pValue) ;
    SetWindowText (hwnd, ValueName) ;

    hwndControl = GetFirstChild (hwnd) ;
    while (NULL != hwndControl) {
        _tcscpy (ValueName, ValueNameBase) ;

        GetWindowText (hwndControl,
                       ValueName + BASECHARS,
                       DIM(ValueName) - BASECHARS) ;


        Result = VerQueryValue (pVerInfo, ValueName, &pValue, &uLength) ;
        if (Result)
            if (0 != uLength && NULL != pValue)
                SetWindowText (hwndControl, pValue) ;

        hwndControl = GetNextSibling (hwndControl) ;
    }
    free (pVerInfo) ;
}

static void
displayOperatingSystemVersionInfo (HWND hwnd)
{
    BOOL                Result ;
    HINSTANCE           hinst ;
    TCHAR               OSVer [256] ;
    TCHAR               FormatString [256] ;

    OSVERSIONINFO       osver ;
    osver.dwOSVersionInfoSize = sizeof (osver) ;

    Result = GetVersionEx (&osver) ;      
    ASSERT (FALSE != Result) ;
    if (FALSE == Result)
        return ;

    hinst = GetWindowInstance (hwnd) ;      

    switch (osver.dwPlatformId) {
        case VER_PLATFORM_WIN32s:          
            LoadString (hinst, IDS_PLATFORM_WIN32s,
                        FormatString, DIM (FormatString)) ;
            break ;

        case VER_PLATFORM_WIN32_WINDOWS:     
            LoadString (hinst, IDS_PLATFORM_WIN32_WINDOWS,
                        FormatString, DIM (FormatString)) ;
            osver.dwBuildNumber = LOWORD (osver.dwBuildNumber) ;
            break ;

        default:                            
            LoadString (hinst, IDS_PLATFORM_UNKNOWN,
                        FormatString, DIM (FormatString)) ;
            break ;
    }

    wsprintf (OSVer, FormatString,
              osver.dwMajorVersion,
              osver.dwMinorVersion,
              osver.dwBuildNumber) ;
    SetDlgItemText (hwnd, IDC_ABOUT_OSVERSION, OSVer) ;
}


static void
displayProcessorVersionInfo (HWND hwnd)
{
    BOOL        Recognized ;
    HINSTANCE   hinst ;
    SYSTEM_INFO si ;
    TCHAR       Buffer [256] ;
    TCHAR       Format [256] ;

    ZeroMemory (&si, sizeof (si)) ;
    GetSystemInfo (&si) ;
    
    hinst = GetWindowInstance (hwnd) ;      

    Recognized = TRUE ;
    switch (si.wProcessorArchitecture) {
        default:
            Recognized = FALSE ;
            LoadString (hinst, IDS_PROCESSOR_ARCHITECTURE_UNKNOWN,
                        Buffer, DIM (Buffer)) ;
            break ;

        case PROCESSOR_ARCHITECTURE_INTEL:  
            switch (si.wProcessorLevel) {
                default:
                    Recognized = FALSE ;
                    LoadString (hinst,
                                IDS_PROCESSOR_LEVEL_INTEL_UNKNOWN,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -