Solved

Resource file question

Posted on 2001-07-03
3
124 Views
Last Modified: 2010-04-06
I want to store a text file in my project's resource file and then load the file into a string when needed. How can I do that? I am not too familiar with the resource file'
thanks in advance
jeco
0
Comment
Question by:jeco
3 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6249755
Here is an example with a jpeg image. A txt file works the same:

http://www.gnomehome.demon.nl/uddf/pages/resource.htm#resource1
0
 

Accepted Solution

by:
VanDamM earned 50 total points
ID: 6251113
it's too easy:

1. create a resource script file (*.RC) with a any text editor (for example: myresource.rc)
fill 1 string:
MyText RCDATA "mytext.txt"
where "mytext.txt" your text file filename

2. and run this command in DOS console:
BRCC32 myresource.rc
this will create a resource file (myresources.res)

3. use in your source code
{$R myresources.res}

4. and for load :
var
 ResourceStream : TResourceStream;

begin
ResourceStream := TResourceStream.CreateFromID(HInstance, MyText, RT_RCDATA);

 and use
LoadFromStream(); (LoadFromStream(ResourceStream);)
 for loading into your component

also see LoadFromResourceName & etc
0
 

Author Comment

by:jeco
ID: 6256532
Thanks, that worked great!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to convert wav to mp3 in delphi 9 200
Delphi Mdi application Child forms get behind control 7 212
Firemonkey webbrowser scrollbars ? 1 38
Delphi...Split view - idea? 1 68
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question