Wednesday, March 17, 2010

Print Screen using C#

int width, height;

width = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width;
height = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height;

Bitmap MyBit;
Rectangle screenRegion = Screen.AllScreens[0].Bounds;
MyBit = new Bitmap(width, height, PixelFormat.Format32bppArgb);

Graphics MyGraph = Graphics.FromImage(MyBit);
MyGraph.CopyFromScreen(screenRegion.Left, screenRegion.Top, 0, 0, screenRegion.Size);

sBit.Save(<>);