如何将TXT文件添加到我的EXE文件中? [英] How do I add a TXT file a resource to my EXE file?
问题描述
但我不想分发这个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 $在使用
列表之后,将项目文件中的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屋!