unit UInspect;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    ComboBox1: TComboBox;
    Label1: TLabel;
    Image1: TImage;
    Label2: TLabel;
    ComboBox2: TComboBox;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure ComboBox1Click(Sender: TObject);
    procedure ComboBox2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var H : THandle = 0;

function MyEnumResNameProc(hModule: THandle; lpType, pszName:PChar; lParam: longint): BOOL;  stdcall;
begin
 if lpType = RT_BITMAP
  then Form1.ComboBox1.Items.Add(pszName)
  else if (lpType = RT_GROUP_ICON) or (lpType = RT_ICON)
  then Form1.ComboBox2.Items.Add(pszName);
 Result := true;
end;

procedure TForm1.Button1Click(Sender: TObject);

begin
 if OpenDialog1.Execute
 then begin
  H := LoadLibrary(PChar(OpenDialog1.FileName));
  if H <> 0
  then begin
   Label1.Caption := 'Файл ' + OpenDialog1.FileName;
   Image1.Picture.Bitmap.Handle := 0;
   Image1.Picture.Icon.Handle := 0;
   ComboBox1.Clear;
   EnumResourceNames(H, RT_BITMAP, @MyEnumResNameProc, 0);
   ComboBox1.ItemIndex := 0;
   ComboBox2.Clear;
   EnumResourceNames(H, RT_GROUP_ICON, @MyEnumResNameProc, 0);
   EnumResourceNames(H, RT_ICON, @MyEnumResNameProc, 0);
   ComboBox2.ItemIndex := 0;
   FreeLibrary(H);
  end;
 end;
end;

procedure TForm1.ComboBox1Click(Sender: TObject);
begin
 H := LoadLibrary(PChar(OpenDialog1.FileName));
 if H <> 0
 then begin
  Image1.Picture.Bitmap.Handle := LoadBitmap(H, PChar(ComboBox1.Text));
  FreeLibrary(H);
 end
 else ShowMessage('Не удалось загрузить изображение');
end;

procedure TForm1.ComboBox2Click(Sender: TObject);
begin
 H := LoadLibrary(PChar(OpenDialog1.FileName));
 if H <> 0
 then begin
  Image1.Picture.Icon.Handle := LoadIcon(H, PChar(ComboBox2.Text));
  FreeLibrary(H);
 end
 else ShowMessage('Не удалось загрузить изображение');
end;

end.
