Screenshots on WinCE

Source: Internet
Author: User

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 ();

}
}
}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.