delphi7剪切板

var
  cl:TClipBoard;
  i,FileNumber:Integer;
  pGlobal:Thandle;                        //存放格式的句柄
  pData:   array[0..MAX_PATH]   of   Char;//存放路径
  temp:Tjpegimage;
begin
   cl:=TClipboard.Create;
   temp:=Tjpegimage.Create;
   cl:=Clipboard;
   if cl. HasFormat(CF_TEXT) then//文本格式
      ShowMessage(cl.AsText);
   if cl.HasFormat(CF_BITMAP) then//word中的图片
     Image1.Picture.LoadFromClipboardFormat(CF_BITMAP,cl.GetAsHandle(CF_BITMAP),0);
   if cl.HasFormat(CF_HDROP) then//文件夹中的图片
   begin
    pGlobal:=cl.GetAsHandle(CF_HDROP);
    if pGlobal>0 then
    begin
      FileNumber:=DragQueryFile(pGlobal,$FFFFFFFF,nil,0);
      for   i:=0   to   FileNumber-1   do   begin
        Fillchar(pData,Sizeof(pData),0);
        DragQueryFile(pGlobal,i,@pData,Sizeof(pData));       //获得路径及文件名
        temp.LoadFromFile(pData);
        Image1.Picture.Bitmap.Assign(temp);
      end;
    end;
   end;
end;

你可能感兴趣的:(delphi7剪切板)