1: procedure TForm1.Button1Click(Sender: TObject);
2: var DCDesk: HDC; // hDC of Desktop
3: bmp: TBitmap;
4: begin
5: {Create a bitmap}
6: bmp := TBitmap.Create;
7:
8: {Set a bitmap sizes}
9: bmp.Height := Screen.Height;
10: bmp.Width := Screen.Width;
11:
12: {Get a desktop DC handle - handle of a display device context}
13: DCDesk := GetWindowDC(GetDesktopWindow);
14:
15: {Copy to any canvas, here canvas of an image}
16: BitBlt(bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height,
17: DCDesk, 0, 0, SRCCOPY);
18:
19: {Save the bitmap}
20: bmp.SaveToFile('ScreenShot.bmp');
21:
22: {Release desktop DC handle}
23: ReleaseDC(GetDesktopWindow, DCDesk);
24:
25: {Release a bitmap}
26: bmp.Free;
27: end;