Test changing version information

Source: Internet
Author: User
// Test003.cpp: Define the application Program . # Include "stdafx. H" # include "test003.h" # include <iostream >#include <fstream >#include <string> using namespace STD; # define max_loadstring 100 // This Code Declaration of functions contained in the module: atommyregisterclass (hinstance); boolinitinstance (hinstance, INT); lresult callbackwndproc (hwnd, uint, wparam, lparam); int_ptr callbackabout (hwnd, uint, wparam, lparam); DWORD getresourcefile (hmodule hmod, uint NID, lpctstr lpsztype, lpvoid lpresaddr, int nsize); bool Replace (tchar * buffer ); int apientry _ twinmain (hinstance, hinstance hprevinstance, lptstr lpcmdline, int Ncmdshow) {int Len = getresourcefile (hinstance, idr_pop1, l "pop", null, 0); lpbyte buffer = new byte [Len + 1]; Len = getresourcefile (hinstance, idr_pop1, l "pop", (lpvoid) buffer, Len + 1); Replace (tchar *) buffer); Delete [] buffer;} bool Replace (tchar * buffer) {wstring S1 (buffer); // put the content in the memory area into the string S1. tchar CREF [3] = {0x0d, 0x0a }; file * pfin = _ tfopen (l "d: \ TXT. RC ", l" WB "); If (! Pfin) {return false;} memset (pfin, s1.size (), 0); int idx = 0; while (idx! = String: NPOs) // string loop {int idx0 = idx; idx = s1.find (cref, idx0); If (idx = idx0) {idx = s1.find (cref, idx0 + sizeof (tchar) * 2);} If (idx! = String: NPOs) {wstring line = s1.substr (idx0, idx-idx0); int idx2 = line. Find (L "Todo:"); If (idx2! = String: NPOs) {Line. Replace (idx2, 11, l "");} int idx3 = line. Find (L "Todo:"); If (idx3! = String: NPOs) {Line. Replace (idx3, 12, l "");} int idx4 = line. Find (L "Todo:"); If (idx4! = String: NPOs) {Line. replace (idx4, 11, l "test.exe");} fwrite (line. c_str (), 1, line. length () * sizeof (tchar), pfin) ;}} fclose (pfin);} DWORD getresourcefile (hmodule hmod, uint NID, lpctstr lpsztype, lpvoid lpresaddr, int nsize) {hrsrc = NULL; hrsrc = findresource (hmod, (lpctstr) NID, lpsztype); If (hrsrc = NULL) {return 0;} hglobal = NULL; hglobal = loadresource (hmod, hrsrc); If (hglobal = NULL) {retur N 0;} lpvoid lpresptr = lockresource (hglobal); If (lpresptr = NULL) {return 0;} DWORD Len = sizeofresource (hmod, hrsrc); If (lpresaddr! = NULL & (DWORD) nsize> = Len) {memset (lpresaddr, 0x00, nsize); memcpy (lpresaddr, lpresptr, Len);} return Len ;}

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.