做过资源文件的进来看看!!!资源文件支持Html文件吗??? (50分)

是的,还有其他什么办法,可以达到我的目的吗?
 
NO
一样可以的
根本不用释放出来的.
 
This is the third article in the series about storing more than just executable code inside a Delphi application.
In the introductory article we saw how Delphi uses standard Windows resource files like icons, bitmaps and cursors. As explained, resource files that store such kind of data can be created with Delphi's Image Editor. The second article explained how to use sound files, video clips, animations and more generally any kind of binary files in a Delphi executable - we placed a mp3 file inside a Delphi exe. As stated, we use Borland Resource Compiler (BRCC32.exe) to create a resource file that gets linked with an executable file.


Creating a HTML page
For the start we have to assemble a (simple) html page. Use your favorite HTML editor and create one page with one associated picture. I'll name mine aboutindex.htm.
Note that when you add a picture tag inside a htm page it looks something like:

<img src="/library/graphics/adp.gif" ...>

We have to alter the IMG tags so that the SRC attribute equals the name we are to give to a picture in a resource:

<img src="ABOUTDP" ...>

My HTML code looks like:

<HTML><HEAD><TITLE>HTML inside a Delphi exe</TITLE></HEAD><BODY>
This is a HTML Delphi resource test:<br>
<img src="/GIF/ABOUTDP" width=106 height=58 border=0 alt="">
</BODY></HTML>


Creating and compiling a resource file
Remember that to create a new resource script file, you have to:
1. Create a new text file in your projects directory.
2. Rename it to AHTMLDelphi.rc.
3. Write down the following two lines of text in the AHTMLDelphi.rc file.

DELPHIINDEX HTML "c:/Delphi/projects/aboutindex.htm"
ABOUTDP GIF "c:/library/graphics/adp.gif"


Note: the resource type "HTML" is RT_HTML, predefined as the resource type "23". This is the default resource type for the RES protocol.

In this way we have prepared one HTML page and one GIF picture to be included in the binary code of our EXE module.

The next step is to compile the .rc file. To compile the AHTMLDelphi.rc file to a .res file execute this command at the command prompt (in the projects directory):

BRCC32 AHTMLDelphi.RC

The final step is to add the following compiler directive to a unit in your project. RES file must be included in the program's build by adding a line like this:

{$R AHTMLDelphi.RES}





Displaying inside a Web browser
When you have the application's exe (let's call it: myhtmldelphi.exe) the HTML resource contained within can be accessed via the RES: protocol. Run Internet Explorer and, in the Address bar, type the following:

res://c:/myhtmldelphi.exe/RT_HTML/DELPHIINDEX

This should result in:



That's it. If you have any questions
like how use the HREF tag inside a html resource, or how to display the html page inside a Delphi form
please post them on the Delphi Programming Forum!
 
jingtao,你能不能说清楚一点,这个我看不明白什么意思?
 
http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/predefined/res.asp
 
经测试发现.直接类型跟名称即可.用RT_HTML反而是不可以的.
微软那个MSDN可能只适用于C.
 
http://www.138soft.com/htm/SoftTip/mycode/ResInHtml.zip
 
多人接受答案了。
 
顶部