Capture your desktop

We can capture your desktop by using the following code.

Use the following namespaces


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.Drawing.Drawing2D;



Use the following code


System.Windows.Forms.PictureBox MyPictureBox = new System.Windows.Forms.PictureBox();
Bitmap MyBitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics MyGraphics = Graphics.FromImage(MyBitmap);
MyGraphics.CopyFromScreen(0, 0, 0, 0, MyBitmap.Size);
MyGraphics.Dispose();
MyPictureBox.Image = MyBitmap;
MyPictureBox.Size = MyBitmap.Size;



Code Explanation

1. Create an instance of PictureBox
2. Create an instance of Bitmap by capturing the current screen
3. By using the class Graphics form a Bitmap
4. Assign the Image into the Picturebox

By
Nathan


Comments

Author: Spidy23 Nov 2009 Member Level: Gold   Points : 1

Hi Nathan,
Instead of desktop screen shot we can put any image right. Then why the heading is specific to desktop?

Author: Nathan23 Nov 2009 Member Level: Gold   Points : 1

Yes Rabiya, But in the above program we are capturing the whole desktop...

We can using this code for spy....the desktop from back end using timer and service.

Author: mohsan naqi04 Apr 2010 Member Level: Bronze   Points : 0

how use this code for asp.net

can some one explain this

Author: mahendar reddy04 Aug 2011 Member Level: Bronze   Points : 0

where to write the given code plz tell me?



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: