Gets the version information for the Windows executable file (revision number)

Source: Internet
Author: User

Earlier on MSDN version information see the introduction of file versions information, looking at the overall complex, has not done. Now need to get the version of the OCX file, so find the next related data, more useful is the vs_fixedfileinfo structure, get this parameter can basically complete the task.

The code is as follows:

1 //typedef struct TAGVS_FIXEDFILEINFO2 //{3 //DWORD dwsignature; /* e.g. 0XFEEF04BD * /4 //DWORD dwstrucversion; /* e.g. 0x00000042 = "0.42" * /5 //DWORD Dwfileversionms; /* e.g. 0x00030075 = "3.75" * /6 //DWORD Dwfileversionls; /* e.g. 0x00000031 = "0.31" * /7 //DWORD Dwproductversionms; /* e.g. 0x00030010 = "3.10" * /8 //DWORD Dwproductversionls; /* e.g. 0x00000031 = "0.31" * /9 //DWORD Dwfileflagsmask; /* = 0x3F for version "0.42" * /Ten //DWORD dwfileflags; /* e.g. Vff_debug | Vff_prerelease * * One //DWORD Dwfileos; /* e.g. VOS_DOS_WINDOWS16 * / A //DWORD Dwfiletype; /* e.g. Vft_driver * / - //DWORD Dwfilesubtype; /* e.g. Vft2_drv_keyboard * / - //DWORD Dwfiledatems; /* e.g. 0 * / the //DWORD Dwfiledatels; /* e.g. 0 * / - //} vs_fixedfileinfo; - { -     CharSzappfullpath[_max_path] = {0}; +  -GetModuleFileName (Null,szappfullpath,max_path);//get the program module name, full path +  A     //get version information for the current file atDWORD Dwlen =GetFileVersionInfoSize (szappfullpath,null); -     Char*pszappversion =New Char[dwlen+1]; -     if(pszappversion) -     { -memset (Pszappversion,0,sizeof(Char) * (dwlen+1)); - GetFileVersionInfo (szappfullpath,null,dwlen,pszappversion); in CString strversion; -UINT Nlen (0); toVs_fixedfileinfo *Pfileinfo (NULL); +VerQueryValue (Pszappversion,"\\", (lpvoid*) &pFileInfo,&nlen); -         if(Pfileinfo) the         { *             //Get File version number $Strversion.format ("%d.%d.%d.%d", HiWord (pfileinfo->dwfileversionms),Panax NotoginsengLoWord (pfileinfo->dwfileversionms), -HiWord (pfileinfo->dwfileversionls), theLoWord (pfileinfo->dwfileversionls)); +         } A     } the}

The basic idea is to get the full path of the executable file, then use the GetFileVersionInfo function to get the version information, and then use the VerQueryValue function to query the version information.

Gets the version information for the Windows executable file (revision number)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.