Struct vs_fixedfileinfo {DWORD dwsignature; // = 0xfeefo4bd DWORD dwstrucversion; // version information of the structure, in DWORD dwfileversionms; // The main file version DWORD dwfileversionls; // file version DWORD dwproductversionms; // main product version DWORD dwproductversionls; // product version DWORD dwfileflagsmask; // file flag mask DWORD dwfileflags; // file flag (whether to include the debugging version, dynamic version structure ...) DWORD dwfileos; // the original file operating system (vos_dos, vos_nt, vos0000windows16 ...) DWORD dwfiletype; // file type (vft_unknown, vft_app, vft_dll ...) DWORD dwfilesubtype; // when dwfiletype is vft_app or vft_dll, this value is 0. When it is driver information vft_app or font information, this value contains its specific information DWORD dwfiledatems; // primary timestamp DWORD dwfiledatels; // timestamp }; ========================================================== ======= struct st_language {word wlanguageid; word wcodepage ;}; cstring STR ("d :\\ test \ test.exe"); DWORD dwsize = getfileversioninfosize (STR, null); If (0 = dwsize) return; lpbyte pblock = (byte *) malloc (dwsize); bool B = getfileversioninfo (STR, 0, dwsize, pblock); char * pvervalue = NULL; uint nlen1 = 0; verqueryvalue (pblock, text ("file: // varfileinfo // translation"), (lpvoid *) & pvervalue, & nlen1); // obtain the language char * planvalue = NULL; uint nlen2 = 0; verqueryvalue (pblock, "varfileinfo \ translation", (lpvoid *) & planvalue, & nlen2 ); // 080404b0 is the Chinese st_language stlang = * (st_language *) planvalue); // gets the verqueryvalue (pblock, text ("file: // % 22 ), (lpvoid *) % 26 pvervalue, % 26nlen1/); vs_fixedfileinfo * pfixfileinfo = (vs_fixedfileinfo *) pvervalue; // you can modify the attributes of pfixfileinfo-> dwfileversionls = 1234; pfixfileinfo-> dwfileversionms = 4321; pfixfileinfo-> dwproductversionls = 101; pfixfileinfo-> dwproductversionms = 1010; // modify the resource handle = beginupdateresource (STR, false ); bool result = updateresource (handle, rt_version, makeintresource (1), stlang. wlanguageid, pblock, dwsize); If (result = false) {afxmessagebox ("updata resource false. ");} endupdateresource (handle, false); free (pblock );
Post: http://www.cppblog.com/kyelin/archive/2007/08/20/30433.html