简体   繁体   English

在resource.rc winapi C ++中的运行时更改文本文件

[英]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. 但是我想更改存储在资源中的txt文件中的文本。 I have read something about it and everyone uses BeginUpdateResource(); UpdateResource(); EndUpdateResource(); 我已经阅读了有关它的内容,每个人都使用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() . 只有这样,您才能使用(Begin/End)UpdateResource()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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