www.pudn.com > DalsaNetlink.rar > CyAboutDlg.cpp


// CyAboutDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "CyApp.h" 
#include "CyAboutDlg.h" 
#include  
#include "iport_version.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CyAboutDlg dialog 
 
 
CyAboutDlg::CyAboutDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CyAboutDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CyAboutDlg) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void CyAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CyAboutDlg) 
	DDX_Control(pDX, IDC_ROOT, mRoot); 
	DDX_Control(pDX, IDC_VERSION, mVersion); 
	DDX_Control(pDX, IDC_LIBRARIES, mLibraries); 
	DDX_Control(pDX, IDC_LICENSING, mLicensing); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CyAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CyAboutDlg) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CyAboutDlg message handlers 
 
BOOL CyAboutDlg::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
    mVersion.SetWindowText( IPORT_RESOURCE_VERSION_STRING ); 
    mLicensing.SetWindowText( IPORT_VERSION_LICENSING_STRING ); 
 
    // prepare the list control 
    mLibraries.InsertColumn( 0, "Library", LVCFMT_LEFT, 230 ); 
    mLibraries.InsertColumn( 1, "Version", LVCFMT_LEFT, 120 ); 
 
    // Prepare the filter 
    CString lDirectory, lFilter, lRoot; 
    char lLocation[4096]; 
    if ( CoyoteSoftwareLocation( lLocation, sizeof( lLocation ) ) == CY_RESULT_OK ) 
    { 
        lDirectory = lLocation;        
        lDirectory += "\\Binaries\\"; 
 
        lRoot.Format( "%s = %s", IPORT_SOFTWARE_ROOT, lLocation ); 
    } 
    else 
    { 
        lRoot.Format( "%s = not defined", IPORT_SOFTWARE_ROOT ); 
    } 
    mRoot.SetWindowText( lRoot ); 
    
    // load the applications and get their version 
    lFilter = lDirectory + "*.exe"; 
    HANDLE lFinder; 
    WIN32_FIND_DATA lData; 
    unsigned char lInfo[ 16384 ]; 
    LPVOID lVersion; 
    UINT lSize = sizeof( lVersion ); 
    int lIndex; 
    if ( ( lFinder = ::FindFirstFile( lFilter, &lData ) ) != INVALID_HANDLE_VALUE ) 
    { 
        // we need to call find next file for the first one 
        do 
        { 
            CString lFileName( lData.cFileName ); 
 
            // get the version info from the file 
            if ( GetFileVersionInfo( (char*)(LPCTSTR)lFileName, NULL, sizeof( lInfo ), lInfo ) && 
                 VerQueryValue( lInfo, "\\StringFileInfo\\040904b0\\FileVersion", &lVersion, &lSize ) ) 
            { 
                char * lPtr = (char *) lVersion; 
 
                // get the current index in the list 
                lIndex = mLibraries.GetItemCount(); 
 
                // insert the item 
                mLibraries.InsertItem( lIndex, lFileName ); 
                mLibraries.SetItemText( lIndex, 1, lPtr ); 
            } 
        } 
        while ( ::FindNextFile( lFinder, &lData ) ); 
 
        FindClose( lFinder ); 
        lFinder = NULL; 
    } 
 
 
    // load the libraries and get their version 
    lFilter = lDirectory + "*.dll"; 
    if ( ( lFinder = ::FindFirstFile( lFilter, &lData ) ) != INVALID_HANDLE_VALUE ) 
    { 
        // we need to call find next file for the first one 
        do 
        { 
            CString lFileName( lData.cFileName ); 
 
            // get the version info from the file 
            if ( GetFileVersionInfo( (char*)(LPCTSTR)lFileName, NULL, sizeof( lInfo ), lInfo ) && 
                 VerQueryValue( lInfo, "\\StringFileInfo\\040904b0\\FileVersion", &lVersion, &lSize ) ) 
            { 
                char * lPtr = (char *) lVersion; 
 
                // get the current index in the list 
                lIndex = mLibraries.GetItemCount(); 
 
                // insert the item 
                mLibraries.InsertItem( lIndex, lFileName ); 
                mLibraries.SetItemText( lIndex, 1, lPtr ); 
            } 
        } 
        while ( ::FindNextFile( lFinder, &lData ) ); 
 
        FindClose( lFinder ); 
        lFinder = NULL; 
    } 
 
	 
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
}