function GetScreenAll: TBitmap; // 截取全屏 var C: TCanvas; begin C := TCanvas.Create; result := TBitmap.Create; result.Width := Screen.Width; result.Height := Screen.Height; C.Handle := GetDC(0); // 獲取屏幕的設備上下文句柄,並拷貝 result.Canvas.CopyRect(Rect(0, 0, screen.Width, screen.Height), C, Rect(0, 0, Screen.Width, SCreen.Height)); ReleaseDC(0, C.Handle); C.Free; end; procedure TForm1.Button2Click(Sender: TObject); var B: TBitmap; begin B := TBitmap.Create; B := GetScreenAll(); B.SaveToFile('d:\test2.bmp'); b.Free; end;