如何将TXT文件添加到我的EXE文件中? [英] How do I add a TXT file a resource to my EXE file?

查看:205
本文介绍了如何将TXT文件添加到我的EXE文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含大约10,000行文本的TXT文件。我想在TMemo中显示这些行。
但我不想分发这个TXT文件我的程序。如何使用 stringtable {} 将其作为资源WITHIUT进行集成,因为这需要每行的标识符(因此我必须添加10000个标识符)。 / p>

_



我有Delphi XE

解决方案

我通常为这种资源创建一个 RC 文件(基本上是一个文本文件),然后添加如

  MyText RCDATA ..\resources\filename.txt 

为RC文件中的每个文件/资源​​。如果RC文件是项目的一部分,它将被编译(到 res )并链接到exe。要使用资源,我通常使用 TResourceStream ,即

  var ResStream: TResourceStream; 
ResStream:= TResourceStream.Create(hInstance,'MyText',RT_RCDATA);

如果在IDE中创建RC文件时没有将RC文件自动添加到项目中,添加行如

  {$ R'myExtraRes.res''myExtraRes.RC'} 
使用
列表之后,将项目文件中的c>


I have a TXT file containing about 10,000 lines of text. I want to display these lines in a TMemo. But I don't want to distribute that TXT file my program. How do I integrate it into my EXE file as a resource WITHIUT using stringtable {} because this requires an identifier for each line (so I will have to add 10000 identifiers).

_

I have Delphi XE

解决方案

I usually create an RC file (which is basically an text file) for this kind of resources, then add line like

MyText RCDATA ..\resources\filename.txt

for each file / resource into the RC file. If the RC file is part of the project it will be compiled (to res) and linked into exe. To use the resource I usually use TResourceStream, ie

var ResStream: TResourceStream;
ResStream := TResourceStream.Create(hInstance, 'MyText', RT_RCDATA);

BTW if the RC file wasn't added to the project automatically when you created it in the IDE then add line like

{$R 'myExtraRes.res' 'myExtraRes.RC'}

into the project file, right after the uses list.

这篇关于如何将TXT文件添加到我的EXE文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆