Full Screen screenshot Program

Source: Internet
Author: User

API function declaration

[System. runtime. interopservices. dllimportattribute ("gdi32.dll")]
Private Static extern bool bitblt (
Intptr hdcdest, // handle of the target device
Int nxdest, // X coordinate in the upper left corner of the target object
Int nydest, // X coordinate in the upper left corner of the target object
Int nwidth, // The width of the rectangle of the target object
Int nheight, // The length of the rectangle of the target object
Intptr hdcsrc, // Source Device handle
Int nxsrc, // X coordinate in the upper left corner of the source object
Int nysrc, // X coordinate in the upper left corner of the source object
System. int32 dwdrop // The operation value of the grating
);

[System. runtime. interopservices. dllimportattribute ("gdi32.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
);


Main Program:

Intptr DC1 = createdc ("display", null, null, (intptr) null );
Graphics G = graphics. fromhdc (DC1 );
Bitmap map = new Bitmap (system. Windows. Forms. Screen. primaryscreen. bounds. Width, system. Windows. Forms. Screen. primaryscreen. bounds. Height, G );
Graphics G1 = graphics. fromimage (MAP );
Intptr DC3 = G. gethdc ();
Intptr DC2 = g1.gethdc ();
Bitblt (DC2, 0, 0, system. windows. forms. screen. primaryscreen. bounds. width, system. windows. forms. screen. primaryscreen. bounds. height, DC3, 0, 0, 13369376 );
G. releasehdc (DC3 );
G1.releasehdc (DC2 );

String dt = datetime. Now. tostring ();
G1.drawstring (datetime. Now. tostring (), new font ("", 36), new solidbrush (color. Red), new point (430,330 ));

Try
{
Map. Save (@ "C:/inetpub/wwwroot/DW/aaa.jpg", system. Drawing. imaging. imageformat. JPEG );
}
Catch
{
}
Finally
{
Map. Dispose ();
GC. Collect ();
}

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.