A program for capturing computer screens

Source: Internet
Author: User
A widget that captures computer screens Program
Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using System. text;
Using System. Windows. forms;
Using System. drawing;
Using System. Drawing. imaging;

Namespace Deskregistrar
{
Class Program
{
// Declare an API Function
[System. runtime. interopservices. dllimportattribute ( " Gdi32.dll " )]
Private   Static   Extern   Bool Bitblt (
Intptr hdcdest, // Handle of the Target DC
Int Nxdest,
Int Nydest,
Int Nwidth,
Int Nheight,
Intptr hdcsrc, // Source DC handle
Int Nxsrc,
Int Nysrc,
System. int32 dwdrop // Grating processing value
);

[System. runtime. interopservices. dllimportattribute ( " Gdi32.dll " )]
Private   Static   Extern Intptr createdc (
String Lpszdriver, // Driver name
String Lpszdevice, // Device Name
String Lpszoutput, // Useless. You can set a "null"
Intptr lpinitdata // Any printer data
);

Static VoidMain (String[] ARGs)
{

System. Threading. Timer =   New System. Threading. Timer ( Delegate (Object O)
{
Intptr DC1 = Createdc ( " Display " , Null , Null , (Intptr) Null );
// Create a DC for the monitor
Graphics G1 = Graphics. fromhdc (DC1 );
// Creates a new graphics object by the handle of a specified device.
Image myimage =   New Bitmap (screen. primaryscreen. bounds. Width, screen. primaryscreen. bounds. Height, G1 );
// Create a bitmap object of the same size as the screen size
Graphics G2 = Graphics. fromimage (myimage );
// Obtain the screen handle
Intptr DC3 = G1.gethdc ();
// Obtain the bitmap handle.
Intptr DC2 = G2.gethdc ();
// Capturing the current screen in the image object
Bitblt (DC2, 0 , 0 , Screen. primaryscreen. bounds. Width, screen. primaryscreen. bounds. Height, DC3, 0 , 0 , 13369376 );
// Copy the current screen to the image
G1.releasehdc (DC3 );
// Release screen handle
G2.releasehdc (DC2 );
// Release bitmap handle
Myimage. Save (appdomain. currentdomain. basedirectory +   " \\ "   + Datetime. Now. tostring ( " Yyyymmddhhmmss " ) +   " . Jpg " , Imageformat. JPEG );
// MessageBox. Show ("the current screen has been saved to the C: \ mydomain.jpg file! ");
}, Null , 0 , 3000 );

console. Read ();
}< BR >}

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.