将大文本文件嵌入到 C++Builder Windows 应用程序中

Embed Large Text File into C++Builder Windows App

我想将一个大型词典文本文件(超过 66k 个单词,每个单词不超过 30 个字符,每行一个单词)嵌入到 运行 的 C++Builder 可执行文件中 Windows。怎么做到的?

与其将文本文件嵌入到可执行文件本身,不如将文件存储在与可执行文件相同的文件夹(或您选择的任何其他文件夹)中,然后在运行时使用 TStringList 对象使用其 LoadFromFile() 方法。

否则,如果您真的想嵌入该文件,您可以将其内容存储在可执行文件的资源中,方法是参考 Embarcadero 文档中带有 .rc script added to the project (or, using the Project > Resources and Images... dialog), and then load the resource data into a TStringList object at runtime using its LoadFromStream() method with a TResourceStream. See Resource Files Support 的文件以获取更多详细信息和示例。

成功使用 Resource Files Support link 将短文本列表文件嵌入到示例 exe 文件中。