delphi 10.2 创建并使用资源文件(一共22种格式,RCDATA是自定义格式)

   windows支持以下资源格式:
  • 1
  • 2
//下面是 Windows 支持的资源格式:
RT_CURSOR       = MakeIntResource(1);
RT_BITMAP       = MakeIntResource(2);
RT_ICON         = MakeIntResource(3);
RT_MENU         = MakeIntResource(4);
RT_DIALOG       = MakeIntResource(5);
RT_STRING       = MakeIntResource(6);
RT_FONTDIR      = MakeIntResource(7);
RT_FONT         = MakeIntResource(8);
RT_ACCELERATOR  = MakeIntResource(9);
RT_RCDATA       = Types.RT_RCDATA; //MakeIntResource(10);
RT_MESSAGETABLE = MakeIntResource(11);
   DIFFERENCE   = 11;
RT_GROUP_CURSOR = MakeIntResource(DWORD(RT_CURSOR + DIFFERENCE));
RT_GROUP_ICON   = MakeIntResource(DWORD(RT_ICON + DIFFERENCE));
RT_VERSION      = MakeIntResource(16);
RT_DLGINCLUDE   = MakeIntResource(17);
RT_PLUGPLAY     = MakeIntResource(19);
RT_VXD          = MakeIntResource(20);
RT_ANICURSOR    = MakeIntResource(21);
RT_ANIICON      = MakeIntResource(22);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
   虽然Windows 规定 RCDATA 用作自定义格式, 我们也可以自定义格式名称, 譬如本例(rc 文件):
  • 1
  • 2
file01 RCDATA "C:Windows
otepad.exe"
fastp myfile res/ceshi.fr3  //自定义为 myfile 格式
  • 1
  • 2
   从资源文件中提取并调用:
  • 1
  • 2
var
  rs: TResourceStream;
begin
  rs := TResourceStream.Create(HInstance, 'file01', RT_RCDATA);
  .....
  rs.Free;
end;

//调用自定义格式的资源文件
var
  rs: TResourceStream;
begin
  rs := TResourceStream.Create(HInstance, 'fastp', 'myfile');
  .....
  rs.Free;
end;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

参考:http://www.cnblogs.com/del/archive/2008/02/15/1069769.html

http://blog.csdn.net/rznice/article/details/77934632

原文地址:https://www.cnblogs.com/findumars/p/8207232.html