473,574 Members | 2,927 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Want screen capture of server desktop

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.FromIm age(myImage);
IntPtr dc1 = gr1.GetHdc();
IntPtr dc2 = GetWindowDC(Get DesktopWindow() );
BitBlt(dc1, 0, 0, 1600, 1200, dc2, 0, 0, 13369376);

Response.Buffer Output=true;
Response.Clear( );
Response.Conten tType="image/gif";
myImage.Save(Re sponse.OutputSt ream, System.Drawing. Imaging.ImageFo rmat.Gif);
Response.End();

Thanks,

Terry

Nov 18 '05 #1
5 2371
I think that you can't get a printscreen on server because the server is
logged off.
You can try changing IIS service property. You can try to check Allow
Interact with desktop flag.

Brun

"Te*********@te ch.com" <an*******@disc ussions.microso ft.com> wrote in
message news:07******** *************** ***********@mic rosoft.com...
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.FromIm age(myImage);
IntPtr dc1 = gr1.GetHdc();
IntPtr dc2 = GetWindowDC(Get DesktopWindow() );
BitBlt(dc1, 0, 0, 1600, 1200, dc2, 0, 0, 13369376);

Response.Buffer Output=true;
Response.Clear( );
Response.Conten tType="image/gif";
myImage.Save(Re sponse.OutputSt ream, System.Drawing. Imaging.ImageFo rmat.Gif); Response.End();

Thanks,

Terry

Nov 18 '05 #2
one
You will probably find more expert at this newsgroup

microsoft.publi c.dotnet.framew ork.drawing
Nov 18 '05 #3
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.

I did try checking "Allow Interact with desktop flag" for the WWW Publishing
service but that didn't seem to help ... is there another service I should also
be checking that flag for?

Terry

----- Bruno Sirianni wrote: -----

I think that you can't get a printscreen on server because the server is
logged off.
You can try changing IIS service property. You can try to check Allow
Interact with desktop flag.

Brun

"Te*********@te ch.com" <an*******@disc ussions.microso ft.com> wrote in
message news:07******** *************** ***********@mic rosoft.com...
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.FromIm age(myImage);
IntPtr dc1 = gr1.GetHdc();
IntPtr dc2 = GetWindowDC(Get DesktopWindow() );
BitBlt(dc1, 0, 0, 1600, 1200, dc2, 0, 0, 13369376);
Response.Buffer Output=true;

Response.Clear( );
Response.Conten tType="image/gif";
myImage.Save(Re sponse.OutputSt ream,

System.Drawing. Imaging.ImageFo rmat.Gif); Response.End();
Thanks,
Terry

Nov 18 '05 #4
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

"Te*********@te ch.com" <an*******@disc ussions.microso ft.com> wrote in
message news:CE******** *************** ***********@mic rosoft.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.

I did try checking "Allow Interact with desktop flag" for the WWW Publishing service but that didn't seem to help ... is there another service I should also be checking that flag for?

Terry

----- Bruno Sirianni wrote: -----

I think that you can't get a printscreen on server because the server is logged off.
You can try changing IIS service property. You can try to check Allow
Interact with desktop flag.

Brun

"Te*********@te ch.com" <an*******@disc ussions.microso ft.com> wrote in
message news:07******** *************** ***********@mic rosoft.com...
> 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.FromIm age(myImage);
> IntPtr dc1 = gr1.GetHdc();
> IntPtr dc2 = GetWindowDC(Get DesktopWindow() );
> BitBlt(dc1, 0, 0, 1600, 1200, dc2, 0, 0, 13369376);
>> Response.Buffer Output=true;

> Response.Clear( );
> Response.Conten tType="image/gif";
> myImage.Save(Re sponse.OutputSt ream,

System.Drawing. Imaging.ImageFo rmat.Gif);
> Response.End();
>> Thanks,
>> Terry

>

Nov 18 '05 #5
I have a service (look like IIS) that can execute applicacation.
1 of this application is used for make graphics (Pie, etc...). The component
I use for render this must have the desktop because if not graph is blank!
I have set interact with desktop property of my service and there is not
problem!

When Application run I can see this!!!!

Brun!
"TerryWilso n" <an*******@disc ussions.microso ft.com> wrote in message
news:F9******** *************** ***********@mic rosoft.com...
OK, I tried spawning a simple application that simply grabs the
desktop and writes the image out to a file. If I run the application directly, 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

"Te*********@te ch.com" <an*******@disc ussions.microso ft.com> wrote in
message news:CE******** *************** ***********@mic rosoft.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.
>> I did try checking "Allow Interact with desktop flag" for the WWW
Publishing
> service but that didn't seem to help ... is there another service I

should also
> be checking that flag for?
>> Terry
>> ----- Bruno Sirianni wrote: -----
>> I think that you can't get a printscreen on server because the server
is
> logged off.
> You can try changing IIS service property. You can try to
check Allow > Interact with desktop flag.
>> Brun
>> "Te*********@te ch.com" <an*******@disc ussions.microso ft.com>
wrote in > message news:07******** *************** ***********@mic rosoft.com... >> 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.FromIm age(myImage);
>> IntPtr dc1 = gr1.GetHdc();
>> IntPtr dc2 = GetWindowDC(Get DesktopWindow() );
>> BitBlt(dc1, 0, 0, 1600, 1200, dc2, 0, 0, 13369376);
>>> Response.Buffer Output=true;
>> Response.Clear( );
>> Response.Conten tType="image/gif";
>> myImage.Save(Re sponse.OutputSt ream,

> System.Drawing. Imaging.ImageFo rmat.Gif);
>> Response.End();
>>> Thanks,
>>> Terry
>>

Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
415
by: Madestro | last post by:
Hi guys, I have a little problem. I have a class that uses Windows API to capture a snapshot of the screen. I have this class in a library that I include in my projects. When I try to use this class in a windows service, the snapshot comes up as a black screen. Any idea why? or how do I get around it? The class works fine if I use it...
0
1639
by: hellokitty | last post by:
GetDC/GetWindowDC can only capture on screen,visually, stuff and not for screen in background If I execute an exe in other desktop, by CreateDesktop/SwitchDesktop, it requires to actually switched into it in order to capture correctly. is it possible to capture a screen in background / in other desktop? *** Sent via Developersdex...
5
1053
by: TerryWilson | last post by:
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...
3
3646
by: Marcob | last post by:
Is there any component out there to capture screen text from a specific region on any active external application form. Thanks Marco
2
6069
by: Juan Romero | last post by:
Guys, I am trying to capture the desktop screen (everything). I am having a problem with the "CreateCompatibleBitmap" API call. For some reason the function is creating a 1x1 pixels bitmap EVERYTIME. I am correctly passing the handles to the function (to the best of my knowledge at least) but it just refuses to create a bitmap in memory...
4
5363
by: gwhite1 | last post by:
I use this code to capture a screen in a regular VB 2005 windows app. It works great! I found the code in google. But when I create a windows service it does not capture the screen. It only captures a blank graphic. Does anyone know why it will not capture the current screen? Is something not available when running as a service? Thanks!!!...
2
10832
by: Rune Strand | last post by:
Is it possible by use of pyWin32 or ctypes to make a screen capture of an inactive, or a hidden window if the hwnd/WindowName/ClassName is known? I've seen dedicated screen capture software do this. While PIL.ImageGrab.grab() is excellent, it will only capture the foreground of the desktop. I've tried for hours, but I soon get helplessly lost...
1
4492
by: JP2006 | last post by:
I'm trying to write a control that will take a screen capture of a particular website when a user submits a form in a web application; one of the form fields is for a URL - the control needs to get an image of that web site so that it can be displayed later as a thumbnail image. I have code for taking a normal screen capture using GDI+ which...
1
2314
by: hemant | last post by:
I am trying to Caputre the screen in windows service with the GDI Api of Win32 in vb.net 1. CreateDc 2. CreateCompatibleDC 3. CreateCompatibleBitmapDc 4. Bitblt 5. SelectObject 6. DeleteDc The Caputured screen file is always black
0
7726
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8098
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6454
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5301
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3752
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2245
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1060
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.