Puede que cometieras el mismo error que yo, la ruta del archivo no puede ser fija, debe ser un buffer lo bastante grande para recibir la ruta del ejecutable. Ya que si nos fijamos bien en la ayuda pone:
Cita:
If the icon handle is obtained from an executable file, the function stores the full path and file name of that executable in the string pointed to by lpIconPath.
|
Entonces la cosa queda así:
Código Delphi
[-]
var
Buffer: array[0..MAX_PATH] of Char;
Icono: TIcon;
Index: Word;
begin
Icono:= TIcon.Create;
try
StrCopy(Buffer,PChar('d:\1.jpg'));
Index:= 0;
Icono.Handle:= ExtractAssociatedIcon(GetModuleHandle(nil),@Buffer,Index);
Canvas.Draw(0,0,Icono);
finally
Icono.Free;
end;
end;