The core code is as follows:
Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Text;
Using System. Windows. Forms;
Using System. Runtime. InteropServices;
Namespace Capture
{
Public partial class Form1: Form
{
[DllImport ("coredll. Dll")]
Private static extern IntPtr CreateDC (
String lpszDriver, // driver name
String lpszDevice, // device name
String lpszOutput, // useless, can be set to "NULL"
IntPtr lpInitData // any printer data
);
[DllImport ("coredll. Dll")]
Private static extern bool BitBlt (
IntPtr hdcDest,
Int nXDest,
Int nYDest,
Int nWidth,
Int nHeight,
IntPtr hdcSrc,
Int nXSrc,
Int nYSrc,
Int32 dwrop
);
Private const int SRCCOPY = 0xCC0020;
Public Form1 ()
{
InitializeComponent ();
}
Private void button#click (object sender, EventArgs e)
{
Int iHeight = Screen. PrimaryScreen. Bounds. Height;
Int iWidth = Screen. PrimaryScreen. Bounds. Width;
IntPtr dc1 = CreateDC (null, (IntPtr) null );
Graphics gScreen = Graphics. FromHdc (dc1 );
Image iGetPhoto = new Bitmap (
IWidth
, IHeight );
Graphics gPhoto = Graphics. FromImage (iGetPhoto );
IntPtr iHandle = gScreen. GetHdc ();
IntPtr iPhoto = gPhoto. GetHdc ();
BitBlt (iPhoto, 0, 0, iWidth, iHeight,
IHandle, 0, 0, SRCCOPY );
GScreen. ReleaseHdc (iHandle );
GPhoto. ReleaseHdc (iPhoto );
IGetPhoto. Save (@ "\ NandFlash \ ice.bmp", System. Drawing. Imaging. ImageFormat. Bmp );
IGetPhoto. Dispose ();
}
}
}