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

📄 about.cpp

📁 MTK bin下载工具全部源代码(c++)
💻 CPP
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2002
*
*****************************************************************************/

/*******************************************************************************
* Filename:
* ---------
*  about.cpp
*
* Project:
* --------
*  Flash tool set
*
* Description:
* ------------
*  about window, display version, build date support feature.
*
* Author:
* -------
*  FZ Hsu (mtk00303)
*
*==============================================================================
*           HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* $Revision:   1.2  $
* $Modtime:   Oct 19 2005 11:11:50  $
* $Log:   //mtkvs01/vmdata/flash_tool/archives/about.cpp-arc  $
 * 
 *    Rev 1.2   Oct 19 2005 14:47:14   mtk00539
 *  1. [FlashTool][New] Adapt new BROM_DLL&DA v2.7.1008. 
 * Resolution for 141: [FlashTool v2.7.1008][New] Support NFB download and many new features.
 * 
 *    Rev 1.1   Jun 30 2003 19:19:34   mtk00539
 *  1. [FlashTool][Add Features] Split flashtool function into brom.dll
 *  2. [FlashTool][Add Features] Format function: users can format any range you want without downloading procedure.
 *  3. [FlashTool][Add Features] Report format percentage.
 *  4. [FlashTool][Add Features] Check format range.
 *  5. [FlashTool][Add Features] Merge FlashTool for Pluto version.
 *  6. [FlashTool][Add Features] Runtime debug log: you can press (CTRL+ALT+T) to enable/disable debug log whenever you want.
 *  7. [FlashTool][Add Features] Forcedly Stop hot-key: you can forcedly stop FlashTool by pressing CTRL+Z.
 *  8. [FlashTool][BUG FIXED] Fix FlashTool MEM_CMD end_addr bug, FlashTool should use (begin_addr+length-1) as end_addr.
 * Resolution for 11: [FlashTool v2.3.1001][New Version] Split flashtool function into brom.dll
 * 
 *    Rev 1.0   Jul 20 2002 19:26:08   admin
 * Initial revision.
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "about.h"
#include "flashtool.h"
#include "meta.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm_About *Form_About;
//---------------------------------------------------------------------------
__fastcall TForm_About::TForm_About(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm_About::Button1Click(TObject *Sender)
{
    Visible = false;        
}
//---------------------------------------------------------------------------
int TForm_About::GetVersion( unsigned int *major_ver, unsigned int *minor_ver, unsigned int *build_num ) {

	static unsigned int s_major_ver=0;
	static unsigned int s_minor_ver=0;
	static unsigned int s_build_num=0;

    if( NULL == major_ver || NULL == minor_ver || NULL == build_num ) {
    	return 1;
	}

    *major_ver = 0;
    *minor_ver = 0;
    *build_num = 0;

	if( 0==s_major_ver && 0==s_minor_ver && 0==s_build_num ) {

		// get file version indo
		DWORD dwHnd;
	 	DWORD dwVerInfoSize;
	 	char *pBuffer;
		if( 0 >= (dwVerInfoSize=GetFileVersionInfoSize("flash_tool.exe", &dwHnd)) ) {
			// get fileversion size error
			return 2;
		}
		if( NULL == (pBuffer=(char *)malloc(dwVerInfoSize)) ) {
			// not enough memory
			return 3;
		}

		// get file version info
		if(!GetFileVersionInfo("flash_tool.exe", dwHnd, dwVerInfoSize, pBuffer)) {
			// get file version info fail
			return 4;
		}

		// get FileVersion string from resource
		VS_FIXEDFILEINFO *p_version;
		unsigned int version_len=0;
		if(!VerQueryValue(pBuffer, "\\", (void **)&p_version, &version_len)) {
			// get query value fail
			return 5;
		}

        /*                                            */
        /* Look at FILEVERSION in rc file.            */
        /*                                            */
        /* FILEVERSION    1,    2,    3,    4         */
        /*             0001  0002  0003  0004         */
        /*             -----+----  -----+----         */
        /*                  |         dwFileVersionLS */
        /*                  |                         */
        /*           dwFileVersionMS                  */
        /*                                            */
		s_major_ver = (p_version->dwFileVersionMS>>16) & 0x0000FFFF;
		s_minor_ver = p_version->dwFileVersionMS & 0x0000FFFF;
		s_build_num = p_version->dwFileVersionLS & 0x0000FFFF;
	}

	// return version number
	*major_ver = s_major_ver;
	*minor_ver = s_minor_ver;
	*build_num = s_build_num;

	return 0;
}

void __fastcall TForm_About::FormCreate(TObject *Sender)
{
   AnsiString as;
   lb_BuildDate->Caption = "Build date: " + AnsiString( __DATE__ );

   unsigned int major_ver;
   unsigned int minor_ver;
   unsigned int build_num;

   GetVersion(&major_ver, &minor_ver, &build_num);

   VersionInfo->Caption = "FlashTool v" + IntToStr(major_ver) + "." + IntToStr(minor_ver) + "." + IntToStr(build_num);

   #ifdef _DEBUG
     as = VersionInfo->Caption;
     as = as+" (DEBUG version) ";
     VersionInfo->Caption = as;
   #endif /* #ifdef _DEBUG */

   unsigned int brom_major_ver;
   unsigned int brom_minor_ver;
   unsigned int brom_build_num;

   GetBromDLLVersion(&brom_major_ver, &brom_minor_ver, &brom_build_num);
   as.printf("brom.dll v%d.%d.%04d", brom_major_ver, brom_minor_ver, brom_build_num);
   brom_dll_version->Caption = as;

   unsigned int metadll_major_ver;
   unsigned int metadll_minor_ver;
   unsigned int metadll_build_num;

   META_GetVersion(&metadll_build_num);
   metadll_major_ver = (0xFF000000&metadll_build_num)>>24;
   metadll_minor_ver = (0x00FF0000&metadll_build_num)>>16;
   metadll_build_num = (0x0000FFFF&metadll_build_num);
   as.printf("META_DLL.dll v%d.%d.%04d", metadll_major_ver, metadll_minor_ver, metadll_build_num);
   meta_dll_version->Caption = as;
}
//---------------------------------------------------------------------------




⌨️ 快捷键说明

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