Forum > Unix

SOLVED Free pascal resource file question. list resources of <type> in .res file

<< < (2/2)

lucamar:
AFAICT TResources has no method called GetName. Try with this (untested, might or might not work):


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program reslist; {$mode objfpc}{$H+} uses  Classes, SysUtils, resource,// You need to specify which resources you want to be able to read.// The units initialize themselves and register themselves as readers....  resreader; var  resources : TResources;  reader : TAbstractResourceReader;  inFile : TFileStream;  i : integer; {$R *.res} begin  resources:=TResources.Create;  inFile:=TFileStream.Create(paramstr(1), fmOpenRead );  // Use FindReader to let TResources find the appropriate reader for the file  reader:=TResources.FindReader(inFile);  writeln('Selected reader: ',reader.Description);  resources.LoadFromStream(inFile,reader);   for i:=0 to resources.Count-1 do  begin    //resread := Tabtractresourcereader.create    writeln(inttostr(i));    writeln(resources.Items[i].Name);  end;   resources.Free;  reader.Free;  inFile.Free;end.

muller59:
Never mind, found an answer

resources.Name.Name does the trick, a bit counter-intuitive IMHO

TRon:

--- Quote from: muller59 on August 17, 2020, 02:54:22 pm ---resources.Name.Name does the trick, a bit counter-intuitive IMHO

--- End quote ---
Yes and no  :D

afaik there are two type of resources as in those that are identified by their name and those that are identified by ID. That is probably why it was implemented the way it is. The counter-intuitive part as far as I am concerned stems from both properties name and _type pointing to class TResourceDesc. That is unless there exists resources that actually can be identified (as in: stored) in both ways.

BTW: You both seem to load the loader manually while I was lazy and included all the individual reader units so I wouldn't have to. No idea what should be the way to actually use it though, or if that even matters.

Edit: my bad. the type property is the resource listing while name property for the actual resource. It is always using either ID or name as indicated by the DescType (sub)property.

--- Code: ---Found 96 resources in file /home/tron/projects/bunch_of_resources
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 1
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 2
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 3
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 4
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 5
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 6
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 7
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 8
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 9
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 10
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 11
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 12
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 13
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 14
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 15
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 16
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 17
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 18
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 19
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 20
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 21
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 22
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 23
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 24
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 25
res.Type.ID   =   1 (RT_CURSOR), res.Name.ID   = 26
res.Type.ID   =   3 (RT_ICON), res.Name.ID   = 1
res.Type.ID   =   3 (RT_ICON), res.Name.ID   = 2
res.Type.ID   =   3 (RT_ICON), res.Name.ID   = 3
res.Type.ID   =   3 (RT_ICON), res.Name.ID   = 4
res.Type.ID   =   3 (RT_ICON), res.Name.ID   = 5
res.Type.ID   =   3 (RT_ICON), res.Name.ID   = 6
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_ABORT
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_ABORT_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_ABORT_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_ALL
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_ALL_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_ALL_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_ARROWRIGHT
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_ARROWRIGHT_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_ARROWRIGHT_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_CANCEL
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_CANCEL_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_CANCEL_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_CLOSE
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_CLOSE_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_CLOSE_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_HELP
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_HELP_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_HELP_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_IGNORE
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_IGNORE_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_IGNORE_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_NO
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_NO_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_NO_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_OK
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_OK_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_OK_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_RETRY
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_RETRY_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_RETRY_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_YES
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_YES_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = BTN_YES_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = DIALOG_CONFIRMATION
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = DIALOG_ERROR
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = DIALOG_INFORMATION
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = DIALOG_SHIELD
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = DIALOG_WARNING
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = SORTASC
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = SORTASC_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = SORTASC_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = SORTASC_50
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = SORTASC_75
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = SORTDESC
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = SORTDESC_150
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = SORTDESC_200
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = SORTDESC_50
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = SORTDESC_75
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = TFRMCLOCKS
res.Type.ID   =  10 (RT_RCDATA), res.Name.Name = TFRMMAIN
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_1
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_10
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_12
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_13
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_14
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_15
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_16
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_17
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_18
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_20
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_21
res.Type.ID   =  12 (RT_GROUP_CURSOR), res.Name.Name = CUR_22
res.Type.ID   =  14 (RT_GROUP_ICON), res.Name.Name = MAINICON
res.Type.ID   =  24 (RT_MANIFEST), res.Name.ID   = 1

--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version