请解释一段代码(从EXE中读图标)(100分)

  • 主题发起人 主题发起人 yeeler
  • 开始时间 开始时间
Y

yeeler

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Timer1Timer(Sender: TObject);
var
AppIcon : TIcon;
IconName : String;
begin
// we're loading icons from the EXE file - they're in the resource file and
// compiled in.
IconName := format('EYES%d',[ AnimateSequence ] );
AppIcon := TIcon.Create;
AppIcon.Handle := LoadIcon( HInstance ,pchar( format('ICON_%d',[ AnimateSequence ] )) );
TrayIcon1.Icon := AppIcon;
AppIcon.Free;
AnimateSequence := AnimateSequence + 1;
if AnimateSequence > 13 then
AnimateSequence := 1;
end;
 
var
AppIcon : TIcon;
IconName : String;
begin
// we're loading icons from the EXE file - they're in the resource file and
// compiled in.
//给ICONNAME 赋初始值
IconName := format('EYES%d',[ AnimateSequence ] );
//
AppIcon := TIcon.Create;
//从EXE的资源中提取图表ICONI
AppIcon.Handle := LoadIcon( HInstance ,pchar( format('ICON_%d',[ AnimateSequence ] )) );
//将图表副给
TrayIcon1.Icon := AppIcon;
AppIcon.Free;
AnimateSequence := AnimateSequence + 1;
if AnimateSequence > 13 then
AnimateSequence := 1;
这段程序是将图表作成动画显示到WIN95 的托盘区
 
请问如果我要从EXE中取其它图标该如何写?怎么查询EXE中的图片?请高手指点,多谢了!
 
uses ShellApi;
var
shf : TShFileInfo;
F_icon : TIcon;
begin
ShGetFileInfo(PChar(sApp),//sApp为Exe文件
0,
shf,
sizeof(shf), shgfi_Icon or
shgfi_DisplayName or
shgfi_sysiconindex or
shgfi_SmallIcon);
F_icon := TIcon.Create;
F_icon.Handle := shf.hIcon;
......
end;
以上代码在D4、D5+windows98下运行通过
 
ExtractIcon(Hinstance,pchar(FileName),0);
HICON ExtractAssociatedIcon(
HINSTANCE hInst, // 应用程序实例句柄
LPTSTR lpIconPath, // 程序的路径和名称
LPWORD lpiIcon // 图表的索引号
);
 
可我不知道EXE resource file中有那些图片,又何从取呢?如同上面一下子取了13幅图做成动画。能解释一下吗?后学晚进恳请大侠们赐教一二,多谢了!
 
Delphi下有例子呀,
C:/Program Files/Borland/Delphi4/Demos/Resxplor
 
可那些图是怎么加进去的呀?我看过源程序,丝毫没有提到那13幅不同的Icon。那些
Icon应该在哪里设置?
 
后退
顶部