/ * Function: Get file version information. Description: To use this function to join #Pragma Comment (Lib, "Version.lib") ------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- -------- Parameters: szsrcfn = Program File Name * / Void getProductVersion (char * szsrcfn) {Word NVER [4]; DWORD DWVERHND = 0;
DWORD dwverinfosize = getFileVersionInFidence ((lpstr) szsrcfn, & dwverhnd); if (dwverinfosize) {// can read file information // The comment portion is another method, not clearly clearing the usage of those functions, slowly watching / / HANDLE hMem; // LPVOID lpvMem; unsigned int uInfoSize = 0; VS_FIXEDFILEINFO * pFileInfo; // hMem = GlobalAlloc (GMEM_MOVEABLE, dwVerInfoSize); // lpvMem = GlobalLock (hMem); // GetFileVersionInfo ((LPSTR) szSrcfn, dwVerHnd, dwVerInfoSize, lpvMem); // VerQueryValue (lpvMem, (LPTSTR) _T ( "//"), (void **) & pFileInfo, & uInfoSize); char * VerData = new char [dwVerInfoSize]; GetFileVersionInfo ((LPSTR) szSrcfn, dwVerHnd , dwverinfosize, (void *) verdata); VERQUERYVALUE ((void *) Verdata, (lptstr) _t ("//"), (void **) & pfileinfo, & uinfosize); // If the version is 1.2.3.4, then NVER [0] = 1, NVER [1] = 2, NVER [2] = 3, NVER [3] = 4
NVER [0] = HiWord (pfileinfo-> dwfileversionms); NVER [1] = loword (pfileinfo-> dwfileversionms); NVER [2] = HiWord (pfileinfo-> dwfileversionls); NVER [3] = loword (PfileInfo-> dwfileVersionls ); Delete [] verdata; // GlobalUnlock (hmem); // GlobalFree (hmem);} // below is FindFirstFile, FileNextFile Usage // FunnexTFILE function: Replace version information in a file (traversal directory), actual Example: Updating the version of the UI in WOW Void ChangeVersion (Char * path, int version) {string pathui = path; Pathui = "//"; handle hfile; win32_find_data filedata; list