欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Using resource files with Delphi

Create the resource file script.

What follows is a step by step instruction for creating resource files.

Resource files can contain text, html documents, sounds, images etc.

Open a simple text editor, e.g. Notepad and enter the files you want to include in your application.

Every line consist of a resource name, a resource type and the resource.

In the example below support is the resource name, HTML is the resource type and "support.html" is the resource.

support HTML "support.html"content HTML "content.html"help    HTML "help.html"bg      JPG  "bg.jpg"back    BMP  "back.bmp"forward BMP  "forward.bmp"home    BMP  "home.bmp"next    GIF  "next.gif"

Save this file with the .rc extension, e.g. myresource.rc.

Compile the resource file.

Now compile myresource.rc with the resource compiler BRCC32.exe which you will find in your Delphi5\bin\ directory.

BRCC32.exe is a command line utility that has the .rc extension associated with it.

Double-click myresource.rc in Windows Explorer and it will be compiled to myresource.res.

Include the resource file in your project.

Enter a statement like {$R .\resources\myresource.res} in your main unit file.

This will look then something like:

implementation{$R *.DFM}{$R .\resources\myresource.res}

Assuming that you keep the resource for a project in a subdirectory called resources , (like I always do for clarity).

Loading the resource file

Next you need a procedure to load a named resource into a memorystream

procedure LoadResourceFile(aFile:string; ms:TMemoryStream);varHResInfo: HRSRC;HGlobal: THandle;Buffer, GoodType : pchar;I: integer;Ext:string;beginext:=uppercase(extractfileext(aFile));ext:=copy(ext,2,length(ext));if ext='HTM' then ext:='HTML';Goodtype:=pchar(ext);aFile:=changefileext(afile,'');HResInfo := FindResource(HInstance, pchar(aFile), GoodType);HGlobal := LoadResource(HInstance, HResInfo);if HGlobal = 0 thenraise EResNotFound.Create('Can''t load resource: '+aFile);Buffer := LockResource(HGlobal);ms.clear;ms.WriteBuffer(Buffer[0], SizeOfResource(HInstance, HResInfo));ms.Seek(0,0);UnlockResource(HGlobal);FreeResource(HGlobal);end;

The TmemoryStream must be created before you call the routine. If you use a lot of resources in your program you can create the variable ms in the FormCreate event and destroy it in the FormDestroy event.

aFile is the name of a resource file to be loaded, without path information.

Personally I always use the method of giving the resource name the same name as the resource file without the extension. This allows for a generic routine like above.

Using the resource file

Finally we want to use the resource file that is now in the TMemoryStream variable ms.

In Delphi many components have a LoadFromStream method that you can use to load the resource.

Suppose we want to load the resource file support.html into a Tstrings.

procedure LoadStringResource;beginList:=TStringList.create;LoadResourceFile('support.html',ms);Memo1.Lines.LoadFromStream(ms);end;

In the above Memo1 is a TMemo.

Alternative method

I received an alternative method from Adrian Meyer which is much shorter:

procedure LoadStringResource2;vartmpStream: TResourceStream;begintmpStream := TResourceStream.Create( HInstance, 'support', 'HTML' );trymemo1.Lines.LoadFromStream( tmpStream );finallytmpStream.Free;end;end;

Conclusion

Compiling resources into your application is easy. I used it in my SbookBuilder program to include all the html docs and images that together make up the user interface. I could have included these files as external files, but this way I am sure that they are always there when the program needs them.

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Web安全:文件上傳漏洞
絕地程序編輯器 此軟件支持多文檔打開(kāi), 種 語(yǔ)言語(yǔ)法高亮度顯示:Delphi,SQL,Basic,C++, Perl, Editor /閱讀器 182萬(wàn)源代碼下載
C# 資源文件(二)
Qt中rcc工具簡(jiǎn)介
delphi 獲得網(wǎng)頁(yè)返回 HTML 文字
如何將文件拷貝到剪貼板
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久