G
Guest
I am developing a web based service tool using asp.net that we will distribute with
our product. This service tool will be used for remotely configuring the product, problem
determination, etc. One thing that I would like to be able to do is display a screen
capture of our product running. I have the code to get the screen capture of the
desktop and I also know how to send the image back to the client to be displayed.
The problem is that the code to grab the desktop image doesn't work when running
in my asp.net code on the server.
From what I have read on the subject, I suspect the problem is that the web server
is running under its own virtual desktop. If so can someone tell me if what I am
trying to do is even possible and if so how. The code I am using is as follows:
(I believe gr1.GetHdc() is where things start to fail).
System.Drawing.Image myImage = new Bitmap(1600, 1200);
Graphics gr1 = Graphics.FromImage(myImage);
IntPtr dc1 = gr1.GetHdc();
IntPtr dc2 = GetWindowDC(GetDesktopWindow());
BitBlt(dc1, 0, 0, 1600, 1200, dc2, 0, 0, 13369376);
Response.BufferOutput=true;
Response.Clear();
Response.ContentType="image/gif";
myImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
Response.End();
Thanks,
Terry
our product. This service tool will be used for remotely configuring the product, problem
determination, etc. One thing that I would like to be able to do is display a screen
capture of our product running. I have the code to get the screen capture of the
desktop and I also know how to send the image back to the client to be displayed.
The problem is that the code to grab the desktop image doesn't work when running
in my asp.net code on the server.
From what I have read on the subject, I suspect the problem is that the web server
is running under its own virtual desktop. If so can someone tell me if what I am
trying to do is even possible and if so how. The code I am using is as follows:
(I believe gr1.GetHdc() is where things start to fail).
System.Drawing.Image myImage = new Bitmap(1600, 1200);
Graphics gr1 = Graphics.FromImage(myImage);
IntPtr dc1 = gr1.GetHdc();
IntPtr dc2 = GetWindowDC(GetDesktopWindow());
BitBlt(dc1, 0, 0, 1600, 1200, dc2, 0, 0, 13369376);
Response.BufferOutput=true;
Response.Clear();
Response.ContentType="image/gif";
myImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
Response.End();
Thanks,
Terry