this slowpoke moves

Extract Icon from any File

procedure TForm1.Button1Click(Sender: TObject);
var
  szFileName: string;
  Icon:       TIcon;
  SHInfo: TSHFileInfo;
begin
 if OpenDialog1.Execute then
 szFileName := OpenDialog1.FileName;
  if FileExists(OpenDialog1.FileName) then
  begin
    try
      Icon := TIcon.Create;
      Icon.Transparent := true;
      SHGetFileInfo(PChar(szFileName), 0, SHInfo, SizeOf(SHInfo), SHGFI_ICON);
      Icon.Handle := SHInfo.hIcon;
      Image1.Transparent := true;
      Image1.Picture.Icon := Icon;
    finally
    Icon.Free;
    end;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   if SaveDialog1.Execute then
   begin
   Image1.Picture.Icon.SaveToFile(SaveDialog1.FileName+'.ico');
   end;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate