In Delphi, how do I read resource files? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiMultimedia/html/delphi_20061110215905161.html
In Delphi, how do I read resource files?
I have an HTML text that is loaded to the current project. Program How can I
? Functions such as createfile and loadfilestream can only be used
Read files from the hard disk.
In addition, how to load an executable file to the project, and then execute
File Read?
Run it on your own!
Use resources.
I just don't know how to do it.
How to load resources, how to read, can you introduce?
A simple example:
Create a text document and add any content named index.htm.
Create a text document and add the following content:
Crnindexhtml rc_data "index.htm"
Save as 1.rc
Add 1. RC to the project and place a memo and a button on the form. In the Click Event of the button:
Procedure tform1.button1click (Sender: tobject );
VaR
RS: tresourcestream;
Begin
RS: = tresourcestream. Create (hinstance, 'crnindexhtml ', 'rc _ data ');
Rs. Position: = 0;
Memo1.lines. loadfromstream (RS );
Rs. Free;
End;
Compile to see the effect.
Above Code Read the HTM resource from the resource and read the content to memo.
To put executable files into resources, do the following:
Upload an EXE file, such as 123.exe, to the project directory, edit the 1. RC file, and add a line:
Crnexefile rc_data "123.exe"
Then in the program:
Procedure tform1.button2click (Sender: tobject );
VaR
RS: tresourcestream;
Begin
RS: = tresourcestream. Create (hinstance, 'crnexefile', 'rc _ data ');
Rs. savetofile ('C: \ ccrun \ 123.exe ');
ShellExecute (handle, 'open', 'c: \ ccrun \ 123.exe ', nil, nil, sw_show );
Rs. Free;
End;
In practice, you can release files from resources to a hidden directory.
The landlord has a lot of points, and the old demon is developed ~~~
Add to favorites
If you do not generate disk files, you must directly map them to the memory for running ..
Don't take all the minutes away from the old demon ~~
Haha, thank you. Old demon solved my problem!
Old demon master, taught!
The sword presents the martyrs, the red powder delivers the beauty, and the old demon receives points!
The amount of money is still coming!
If you have the opportunity, please consult the old demon later!
I don't know how to implement the methods described by vividw?