补充一句:还有一个ExtractAssociatedIcon函数
procedure TForm1.Button1Click(Sender: TObject);
var
IconIndex : word;
h : hIcon;
begin
IconIndex := 0;
h :=
ExtractAssociatedIcon(hInstance,
'C:/WINDOWS/NOTEPAD.EXE',
IconINdex);
DrawIcon(Form1.Canvas.Handle,
10,
10,
h);
The ExtractAssociatedIcon function first looks for
the indexed icon in the file specified by lpIconPath.
If the function cannot obtain the icon handle from that file,
and the file has an associated executable file,
it looks in that executable file for an icon.
Associations with executable files are based on filename extensions,
are stored in the per-user part of the registry,
and can be defined using File Manager's Associate command.