I am developing a web based service tool using asp.net that we will distribu
te with
our product. This service tool will be used for remotely configuring the pr
oduct, 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 o
f the
desktop and I also know how to send the image back to the client to be displ
ayed.
The problem is that the code to grab the desktop image doesn't work when run
ning
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 foll
ows:
(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,
TerryOK, I tried spawning a simple application that simply grabs the
desktop and writes the image out to a file. If I run the application direct
ly,
it works as expected, however, when I spawn it from my aspx page
on the server I simply get a blank image written out to the file.
I still think the key (as I read in another post in this group) is that the
web server is running as a service in some virtual desktop that is different
from the visible desktop. So how do you get the window handle to the
currently visible desktop?
Terry
-- Bruno Sirianni wrote: --
I have tryed yuor code and read MSDN documentation.
gr1.GetHdc() return the device context for a Windows GDI-based structure.
ASP.NET is not in a windows form!!
You can try making a simple form application that do this.
You can run this exe and then get the image...
Brun
"TerryWilson@.tech.com" <anonymous@.discussions.microsoft.com> wrote in
message news:CE6A04C6-4F60-4CAB-BF85-E13C19893197@.microsoft.com...
> I am not sure what you mean by "the server is logged off". In this case,
> our product will be running on the server at the time I wish to do the
screen
> capture, so it will have been logged onto by someone.
Publishing
> service but that didn't seem to help ... is there another service I should
also
> be checking that flag for?
is
> logged off.
> You can try changing IIS service property. You can try to check Allow
> Interact with desktop flag.
> message news:07197D0B-C189-4B67-87C0-61586A6D2CEA@.microsoft.com...
> distribute with
configuring the
> product, problem
is
> display a screen
capture
> of the
be
> displayed.
when
> running
that the
> web server
me if
> what I am
is as
> follows:
> System.Drawing.Imaging.ImageFormat.Gif);
0 comments:
Post a Comment