简体   繁体   中英

Change text file on runtime in resource.rc winapi c++

I would like to read from file in resource file. That's ok like so:

char LineBuffer[255]; HRSRC hRes = FindResource(0, MAKEINTRESOURCE(ID_TEXT_FILE), "0"); if(hRes != NULL) { HGLOBAL hData = LoadResource(0, hRes); if(hData != NULL) { sprintf(LineBuffer, "%s", LockResource(hData)); } }

But I want to change the text in the txt file stored in resource. I have read something about it and everyone uses BeginUpdateResource(); UpdateResource(); EndUpdateResource(); BeginUpdateResource(); UpdateResource(); EndUpdateResource(); but I don't get it. Any help would be appreciated :) A code snippet would be awesome. Thanks in advance ;-)

A running process cannot alter its own resources. You have to use a separate application to update the resources of the main application while it is not running. Only then can you use (Begin/End)UpdateResource() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM