Want screen capture of server desktop

Discussion in 'ASP .Net' started by =?Utf-8?B?VGVycnlXaWxzb25AdGVjaC5jb20=?=, Apr 5, 2004.

  1. 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
     
    =?Utf-8?B?VGVycnlXaWxzb25AdGVjaC5jb20=?=, Apr 5, 2004
    #1
    1. Advertising

  2. 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

    "" <> wrote in
    message news:...
    > 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
    >
     
    Bruno Sirianni, Apr 5, 2004
    #2
    1. Advertising

  3. You will probably find more expert at this newsgroup

    microsoft.public.dotnet.framework.drawing
     
    =?Utf-8?B?b25l?=, Apr 5, 2004
    #3
  4. 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

    "" <> wrote in
    message news:...
    > 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

    >
     
    =?Utf-8?B?VGVycnlXaWxzb25AdGVjaC5jb20=?=, Apr 6, 2004
    #4
  5. 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

    "" <> wrote in
    message news:...
    > 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
    >
    > "" <> wrote in
    > message news:...
    > > 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

    > >
     
    Bruno Sirianni, Apr 6, 2004
    #5
  6. 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!


    "TerryWilson" <> wrote in message
    news:...
    > 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
    >
    > "" <> wrote in
    > message news:...
    > > 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
    > >> "" <>

    wrote in
    > > message

    news:...
    > >> 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
    > >>
     
    Bruno Sirianni, Apr 6, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. D Sheldon

    ASP.Net screen capture method

    D Sheldon, Jun 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,898
    anchamparuthi
    Jul 6, 2006
  2. Phil Winstanley [Microsoft MVP ASP.NET]

    Re: ASP.Net screen capture method

    Phil Winstanley [Microsoft MVP ASP.NET], Jun 24, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    640
    Phil Winstanley [Microsoft MVP ASP.NET]
    Jun 24, 2004
  3. TC
    Replies:
    4
    Views:
    667
    JohnnyAppleseed
    Feb 7, 2005
  4. Max
    Replies:
    7
    Views:
    9,124
  5. iMath
    Replies:
    7
    Views:
    1,903
    iMath
    Nov 10, 2013
Loading...

Share This Page