Last post Sep 22, 2009 07:13 AM by vyombhar
Sep 22, 2009 07:13 AM|vyombhar|LINK
I have tried to use the “COPYFROMSCREEN” method of SYSTEM.GRAPHICS
and tried to write this in the memory stream.
The following Code Worked Perfectly while I was running through VS.net 2005.
MemoryStream ms = new MemoryStream();
Bitmap bmp = new Bitmap(1280, 1024);//Creating BMP object
Graphics gpx = Graphics.FromImage(bmp);//attaching Graphics
gpx.CopyFromScreen(0, 0, 0, 0, new Size(1280, 1024));
//Doing Copy from Screen to capture Client Scren
//SAVING the BMP in the Memory stream MS
Byte buffer = ms.ToArray();
// changing the Memory Stream object to ms
//flushing the content in ms.
//closing the stream
fs = new FileStream(fname, FileMode.Create, FileAccess.ReadWrite);
fs.Write(buffer, 0, Convert.ToInt32(buffer.Length));
//Writing the Content in ”D://errorimg//error.gif”.
When I hosted the I got Following errors
THE HANLDE IS INVALID.
Exception Details: System.ComponentModel.Win32Exception
I tried to Use other methods but they all are pointing to windows application.
I am very upset.
Can any one tell me the solution.