Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 572
  • Last Modified:

determine number of resources in a file


i know , in delphi 7, i can do this to extract one resource named "ResourceName" from currently running app,

var
  rStream := TResourceStream;

begin
  rStream := TResourceStream.Create(0, 'ResourceName', RT_RCDATA);
  rStream.SaveToFile('filepath');
end;


but how to extract all resource files within a resource type,, how to determine their number, names or if one exists or not ??

0
AgentAmine
Asked:
AgentAmine
1 Solution
 
epasquierCommented:
check this :
http://msdn.microsoft.com/en-us/library/ms648037%28VS.85%29.aspx

and here is an example to use it :
http://www.swissdelphicenter.ch/torry/showcode.php?id=1710

be aware that in this example, the function that adds all resources found to the list adds a space before all names, and for the resources that are not named but only have an ID, they are marked with a # and ID number

I striped the spaces in the function below :
function enumResNamesProc(module: HMODULE; restype, resname: PChar;
  list: TStrings): Integer; stdcall;
begin
  if HiWord(Cardinal(resname)) <> 0 then
    list.Add(resname)
  else
    list.Add(Format('#%d', [loword(Cardinal(resname))]));
  Result := 1;
end;

Open in new window

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now