{codecitation class="brush: pascal; gutter: false;" width="600px"}

Оформил: DeeCo

Автор: http://www.swissdelphicenter.ch

function EnumResTypes (hMod: THandle; restype, resname: PChar; Lines: TStrings): BOOL; stdcall;

var

ms: TMemoryStream;

rs: TResourceStream;

S: string;

i: Integer;

begin

Result:= True;

SetLength (S, 10000);

if Assigned (resname) then

begin

rs:= TResourceStream.Create (hinstance, resname, restype);

try

try

ms:= TMemoryStream.Create;

try

ObjectBinaryToText (rs, ms);

SetLength (S, ms.Size);

ms.Position:= 0;

ms.read (S[1], ms.Size);

Lines.Add (resname);

Lines.Add ('Length of data is ' IntToStr (Length (S)));

i:= Pos (#13, S);

if i > 0 then

begin

SetLength (S, i — 1);

Lines.Add (S);

i:= Pos ('object', S);

if i > 0 then

begin

Delete (S, 1, i 6);

i:= Pos (' ', S);

if i > 0 then

begin

Lines.Add ('Form name is: ' Copy (S, 1, i — 2));

Delete (S, 1, i);

Lines.Add ('Form class is: ' S);

end;

end

end

else

begin

// Lines.Add ('This resource seems not to hold a form');

end;

finally

ms.Free

end;

except

// Lines.Add ('This resource is not a form resource');

end;

finally

rs.Free;

end;

end;

end;

procedure TForm1.Button1Click (Sender: TObject);

begin

if not EnumResourceNames (0, RT_RCDATA, @EnumResTypes, Integer (Memo1.Lines)) then

Memo1.Lines.Add ('Error, GetLastError Returns ' IntToHex (GetLastError, 8));

end;

{/codecitation}