搞定了,还是要感谢雪鹰,虽然他讲的不是很详细:
比如存放TBitmap和文字:
procedure TfrmMain.asd(Sender: TObject);
var
f: word; data: cardinal; palette: hpalette;
size: Integer;
s: string;
DataPtr: Pointer;
begin
Clipboard.Clear;
Clipboard.Open;
try
image1.Picture.Bitmap.SaveToClipboardFormat(f, data, palette);
SetClipboardData(f, data);
s := Edit1.Text;
size := Length(s) + 1;
Data := GlobalAlloc(GMEM_MOVEABLE + GMEM_DDESHARE, Size);
try
DataPtr := GlobalLock(Data);
try
Move(Pointer(s)^, DataPtr^, Size);
SetClipboardData(CF_TEXT, Data);
finally
GlobalUnlock(Data);
end;
except
GlobalFree(Data);
raise;
end;
finally
Clipboard.Close;
end;
end;