在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
该程序能够监视Windows剪切板的内容(文字和图片) 其思路是
主要代码如下:
procedure TForm1.FormCreate(Sender: TObject); begin hwndNextViewer:= SetClipBoardViewer(Self.Handle); end; procedure TForm1.DrawclipBoard(var message: Tmessage); begin lbl1.Caption := '' ; if (hwndNextViewer<>0) then SendMessage(hwndNextViewer,message.Msg,message.WParam,message.LParam); PaintClip; end; procedure TForm1.FormDestroy(Sender: TObject); begin changeclipboardChain(handle,hwndNextViewer); end; procedure TForm1.ChangecbChain(var message: Tmessage); begin if (message.WParam=hwndNextViewer) then hwndNextViewer := message.LParam else if(hwndNextViewer<>0) then SendMessage(hwndNextViewer,message.Msg,message.WParam,message.LParam); end; procedure TForm1.PaintClip; Var htext,hBitmap:HGLOBAL; str:String; pch:Pointer; len:Integer; begin openclipboard(Self.Handle); htext := GetClipboardData(CF_TEXT); hBitmap := GetClipboardData(CF_BITMAP); if htext<>0 then begin pch:=globallock(htext); len:= globalSize(htext); SetString(str,Pchar(pch),len); lbl1.Caption := lbl1.Caption + str; globalunlock(htext); end; if hBitmap<>0 then begin img1.Picture.Bitmap.Handle := hBitmap; end; CloseClipBoard; end;
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论