Delphi: Saving Clipboard image to file in code

Question

I have managed to copy a Form which was set up as a custom report with GetFormImage to clipboard. It shows the complete image of the form when pasted on wordpad.
How can I save this image on the clipboard as a file on the harddrive from code?

Answer

The Clipboard can not be saved directly to a file. Solution: put the Clipboard contents in a Delphi TPicture and next save the TPicture in a file, it will be written in bitmap format.

if Clipboard.HasFormat(CF_BITMAP) then begin
  Image1.Picture.Assign(Clipboard);
  Image1.Picture.SaveToFile('c:\test\abc.bmp');
end;