GDI+ problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pohihihi

    GDI+ problem

    I am getting a generic GDI+ error on following code. Basically it is trying
    to capture screen image and save in a file.
    Is there a way to find more details on this error? Thanks for the help.

    ---------------------------
    ERROR MSG
    ---------------------------
    System.Runtime. InteropServices .ExternalExcept ion: A generic error occurred
    in GDI+.
    at System.Drawing. Image.Save(Stri ng filename, ImageCodecInfo encoder,
    EncoderParamete rs encoderParams)
    at System.Drawing. Image.Save(Stri ng filename, ImageFormat format)
    at ScreenCapture.F orm1.TakeSnapNo w() in c:\visual studio
    projects\screen capture\form1.c s:line 102



    Sorry for the formating below.

    //First, you need to import the BitBlt, GetDC and ReleaseDC functions.

    //imports the GDI BitBlt function that enables the background of the window

    //to be captured

    [DllImport("gdi3 2.dll")]

    private static extern bool BitBlt(

    IntPtr hdcDest, // handle to destination DC

    int nXDest, // x-coord of destination upper-left corner

    int nYDest, // y-coord of destination upper-left corner

    int nWidth, // width of destination rectangle

    int nHeight, // height of destination rectangle

    IntPtr hdcSrc, // handle to source DC

    int nXSrc, // x-coordinate of source upper-left corner

    int nYSrc, // y-coordinate of source upper-left corner

    System.Int32 dwRop // raster operation code

    );


    [DllImport("User 32.dll")]

    public extern static System.IntPtr GetDC(System.In tPtr hWnd);

    [DllImport("User 32.dll")]

    public extern static int ReleaseDC(Syste m.IntPtr hWnd, System.IntPtr hDC);
    //modified to include hWnd


    //Now, to capture the screen in it's entirety you can do the following.

    public void TakeSnapNow()

    {

    System.IntPtr desktopDC=GetDC (System.IntPtr. Zero);

    Bitmap bm=new Bitmap(SystemIn formation.Virtu alScreen.Width,
    SystemInformati on.VirtualScree n.Height);

    try

    {

    Graphics g=Graphics.From Image(bm);

    System.IntPtr bmDC=g.GetHdc() ;

    BitBlt(bmDC,0,0 ,bm.Width,bm.He ight,desktopDC, 0,0,0x00CC0020 /*SRCCOPY*/);

    bm.Save("C:\fil e.bmp",System.D rawing.Imaging. ImageFormat.Bmp );

    ReleaseDC(Syste m.IntPtr.Zero, desktopDC);

    g.ReleaseHdc(bm DC);

    g.Dispose();

    }

    catch(Exception er)

    {

    MessageBox.Show (er.ToString()) ;

    }

    }



  • Mark R. Dawson

    #2
    RE: GDI+ problem



    "Pohihihi" wrote:
    [color=blue]
    > I am getting a generic GDI+ error on following code. Basically it is trying
    > to capture screen image and save in a file.
    > Is there a way to find more details on this error? Thanks for the help.
    >
    > ---------------------------
    > ERROR MSG
    > ---------------------------
    > System.Runtime. InteropServices .ExternalExcept ion: A generic error occurred
    > in GDI+.
    > at System.Drawing. Image.Save(Stri ng filename, ImageCodecInfo encoder,
    > EncoderParamete rs encoderParams)
    > at System.Drawing. Image.Save(Stri ng filename, ImageFormat format)
    > at ScreenCapture.F orm1.TakeSnapNo w() in c:\visual studio
    > projects\screen capture\form1.c s:line 102
    >
    >
    >
    > Sorry for the formating below.
    >
    > //First, you need to import the BitBlt, GetDC and ReleaseDC functions.
    >
    > //imports the GDI BitBlt function that enables the background of the window
    >
    > //to be captured
    >
    > [DllImport("gdi3 2.dll")]
    >
    > private static extern bool BitBlt(
    >
    > IntPtr hdcDest, // handle to destination DC
    >
    > int nXDest, // x-coord of destination upper-left corner
    >
    > int nYDest, // y-coord of destination upper-left corner
    >
    > int nWidth, // width of destination rectangle
    >
    > int nHeight, // height of destination rectangle
    >
    > IntPtr hdcSrc, // handle to source DC
    >
    > int nXSrc, // x-coordinate of source upper-left corner
    >
    > int nYSrc, // y-coordinate of source upper-left corner
    >
    > System.Int32 dwRop // raster operation code
    >
    > );
    >
    >
    > [DllImport("User 32.dll")]
    >
    > public extern static System.IntPtr GetDC(System.In tPtr hWnd);
    >
    > [DllImport("User 32.dll")]
    >
    > public extern static int ReleaseDC(Syste m.IntPtr hWnd, System.IntPtr hDC);
    > //modified to include hWnd
    >
    >
    > //Now, to capture the screen in it's entirety you can do the following.
    >
    > public void TakeSnapNow()
    >
    > {
    >
    > System.IntPtr desktopDC=GetDC (System.IntPtr. Zero);
    >
    > Bitmap bm=new Bitmap(SystemIn formation.Virtu alScreen.Width,
    > SystemInformati on.VirtualScree n.Height);
    >
    > try
    >
    > {
    >
    > Graphics g=Graphics.From Image(bm);
    >
    > System.IntPtr bmDC=g.GetHdc() ;
    >
    > BitBlt(bmDC,0,0 ,bm.Width,bm.He ight,desktopDC, 0,0,0x00CC0020 /*SRCCOPY*/);
    >
    > bm.Save("C:\fil e.bmp",System.D rawing.Imaging. ImageFormat.Bmp );
    >
    > ReleaseDC(Syste m.IntPtr.Zero, desktopDC);
    >
    > g.ReleaseHdc(bm DC);
    >
    > g.Dispose();
    >
    > }
    >
    > catch(Exception er)
    >
    > {
    >
    > MessageBox.Show (er.ToString()) ;
    >
    > }
    >
    > }
    >
    >
    >
    >[/color]

    Comment

    • Mark R. Dawson

      #3
      RE: GDI+ problem

      Hi Pohihihi,
      on the line:

      bm.Save("C:\fil e.bmp",System.D rawing.Imaging. ImageFormat.Bmp );

      I believe that having a single \ will cause problems because \<char> is
      regarded as an escape character.

      Try:
      bm.Save(@"C:\fi le.bmp",System. Drawing.Imaging .ImageFormat.Bm p);
      which the @ means use the literal value of the string ignoring escape
      characters

      or
      bm.Save("C:\\fi le.bmp",System. Drawing.Imaging .ImageFormat.Bm p);


      Hope that helps.
      Mark

      "Pohihihi" wrote:
      [color=blue]
      > I am getting a generic GDI+ error on following code. Basically it is trying
      > to capture screen image and save in a file.
      > Is there a way to find more details on this error? Thanks for the help.
      >
      > ---------------------------
      > ERROR MSG
      > ---------------------------
      > System.Runtime. InteropServices .ExternalExcept ion: A generic error occurred
      > in GDI+.
      > at System.Drawing. Image.Save(Stri ng filename, ImageCodecInfo encoder,
      > EncoderParamete rs encoderParams)
      > at System.Drawing. Image.Save(Stri ng filename, ImageFormat format)
      > at ScreenCapture.F orm1.TakeSnapNo w() in c:\visual studio
      > projects\screen capture\form1.c s:line 102
      >
      >
      >
      > Sorry for the formating below.
      >
      > //First, you need to import the BitBlt, GetDC and ReleaseDC functions.
      >
      > //imports the GDI BitBlt function that enables the background of the window
      >
      > //to be captured
      >
      > [DllImport("gdi3 2.dll")]
      >
      > private static extern bool BitBlt(
      >
      > IntPtr hdcDest, // handle to destination DC
      >
      > int nXDest, // x-coord of destination upper-left corner
      >
      > int nYDest, // y-coord of destination upper-left corner
      >
      > int nWidth, // width of destination rectangle
      >
      > int nHeight, // height of destination rectangle
      >
      > IntPtr hdcSrc, // handle to source DC
      >
      > int nXSrc, // x-coordinate of source upper-left corner
      >
      > int nYSrc, // y-coordinate of source upper-left corner
      >
      > System.Int32 dwRop // raster operation code
      >
      > );
      >
      >
      > [DllImport("User 32.dll")]
      >
      > public extern static System.IntPtr GetDC(System.In tPtr hWnd);
      >
      > [DllImport("User 32.dll")]
      >
      > public extern static int ReleaseDC(Syste m.IntPtr hWnd, System.IntPtr hDC);
      > //modified to include hWnd
      >
      >
      > //Now, to capture the screen in it's entirety you can do the following.
      >
      > public void TakeSnapNow()
      >
      > {
      >
      > System.IntPtr desktopDC=GetDC (System.IntPtr. Zero);
      >
      > Bitmap bm=new Bitmap(SystemIn formation.Virtu alScreen.Width,
      > SystemInformati on.VirtualScree n.Height);
      >
      > try
      >
      > {
      >
      > Graphics g=Graphics.From Image(bm);
      >
      > System.IntPtr bmDC=g.GetHdc() ;
      >
      > BitBlt(bmDC,0,0 ,bm.Width,bm.He ight,desktopDC, 0,0,0x00CC0020 /*SRCCOPY*/);
      >
      > bm.Save("C:\fil e.bmp",System.D rawing.Imaging. ImageFormat.Bmp );
      >
      > ReleaseDC(Syste m.IntPtr.Zero, desktopDC);
      >
      > g.ReleaseHdc(bm DC);
      >
      > g.Dispose();
      >
      > }
      >
      > catch(Exception er)
      >
      > {
      >
      > MessageBox.Show (er.ToString()) ;
      >
      > }
      >
      > }
      >
      >
      >
      >[/color]

      Comment

      • Pohihihi

        #4
        Re: GDI+ problem

        Thanks Mark that was the real cause. I was looking all around to find the
        problem.
        I am still interested in learning how to trap errors while using interops.


        "Mark R. Dawson" <MarkRDawson@di scussions.micro soft.com> wrote in message
        news:5186DA9D-7726-4CE2-95A3-C3BE6B9BB5A3@mi crosoft.com...[color=blue]
        > Hi Pohihihi,
        > on the line:
        >
        > bm.Save("C:\fil e.bmp",System.D rawing.Imaging. ImageFormat.Bmp );
        >
        > I believe that having a single \ will cause problems because \<char> is
        > regarded as an escape character.
        >
        > Try:
        > bm.Save(@"C:\fi le.bmp",System. Drawing.Imaging .ImageFormat.Bm p);
        > which the @ means use the literal value of the string ignoring escape
        > characters
        >
        > or
        > bm.Save("C:\\fi le.bmp",System. Drawing.Imaging .ImageFormat.Bm p);
        >
        >
        > Hope that helps.
        > Mark
        >
        > "Pohihihi" wrote:
        >[color=green]
        >> I am getting a generic GDI+ error on following code. Basically it is
        >> trying
        >> to capture screen image and save in a file.
        >> Is there a way to find more details on this error? Thanks for the help.
        >>
        >> ---------------------------
        >> ERROR MSG
        >> ---------------------------
        >> System.Runtime. InteropServices .ExternalExcept ion: A generic error
        >> occurred
        >> in GDI+.
        >> at System.Drawing. Image.Save(Stri ng filename, ImageCodecInfo encoder,
        >> EncoderParamete rs encoderParams)
        >> at System.Drawing. Image.Save(Stri ng filename, ImageFormat format)
        >> at ScreenCapture.F orm1.TakeSnapNo w() in c:\visual studio
        >> projects\screen capture\form1.c s:line 102
        >>
        >>
        >>
        >> Sorry for the formating below.
        >>
        >> //First, you need to import the BitBlt, GetDC and ReleaseDC functions.
        >>
        >> //imports the GDI BitBlt function that enables the background of the
        >> window
        >>
        >> //to be captured
        >>
        >> [DllImport("gdi3 2.dll")]
        >>
        >> private static extern bool BitBlt(
        >>
        >> IntPtr hdcDest, // handle to destination DC
        >>
        >> int nXDest, // x-coord of destination upper-left corner
        >>
        >> int nYDest, // y-coord of destination upper-left corner
        >>
        >> int nWidth, // width of destination rectangle
        >>
        >> int nHeight, // height of destination rectangle
        >>
        >> IntPtr hdcSrc, // handle to source DC
        >>
        >> int nXSrc, // x-coordinate of source upper-left corner
        >>
        >> int nYSrc, // y-coordinate of source upper-left corner
        >>
        >> System.Int32 dwRop // raster operation code
        >>
        >> );
        >>
        >>
        >> [DllImport("User 32.dll")]
        >>
        >> public extern static System.IntPtr GetDC(System.In tPtr hWnd);
        >>
        >> [DllImport("User 32.dll")]
        >>
        >> public extern static int ReleaseDC(Syste m.IntPtr hWnd, System.IntPtr
        >> hDC);
        >> //modified to include hWnd
        >>
        >>
        >> //Now, to capture the screen in it's entirety you can do the following.
        >>
        >> public void TakeSnapNow()
        >>
        >> {
        >>
        >> System.IntPtr desktopDC=GetDC (System.IntPtr. Zero);
        >>
        >> Bitmap bm=new Bitmap(SystemIn formation.Virtu alScreen.Width,
        >> SystemInformati on.VirtualScree n.Height);
        >>
        >> try
        >>
        >> {
        >>
        >> Graphics g=Graphics.From Image(bm);
        >>
        >> System.IntPtr bmDC=g.GetHdc() ;
        >>
        >> BitBlt(bmDC,0,0 ,bm.Width,bm.He ight,desktopDC, 0,0,0x00CC0020 /*SRCCOPY*/);
        >>
        >> bm.Save("C:\fil e.bmp",System.D rawing.Imaging. ImageFormat.Bmp );
        >>
        >> ReleaseDC(Syste m.IntPtr.Zero, desktopDC);
        >>
        >> g.ReleaseHdc(bm DC);
        >>
        >> g.Dispose();
        >>
        >> }
        >>
        >> catch(Exception er)
        >>
        >> {
        >>
        >> MessageBox.Show (er.ToString()) ;
        >>
        >> }
        >>
        >> }
        >>
        >>
        >>
        >>[/color][/color]


        Comment

        • Mark R. Dawson

          #5
          Re: GDI+ problem

          For looking what the exact error was through the interop services you can get
          the last error from the Win32 calls, although you cannot call the
          GetLastError method directly, you must go through a method called
          GetLastWin32Err or.

          Basically make sure you have imported the namespace
          System.Runtime. InteropServices then when you import a DLL you need to set the
          SetLastError property to true i.e.

          [DllImport("gdi3 2.dll", SetLastError=tr ue)]

          Then when you have an exception you can do:

          intError = Marshal.GetLast Win32Error();

          which returns the error code.

          I am not an expert in this, but this might be enough to get you pointed in
          the right direction.

          Hope that helps
          Mark.

          "Pohihihi" wrote:
          [color=blue]
          > Thanks Mark that was the real cause. I was looking all around to find the
          > problem.
          > I am still interested in learning how to trap errors while using interops.
          >
          >
          > "Mark R. Dawson" <MarkRDawson@di scussions.micro soft.com> wrote in message
          > news:5186DA9D-7726-4CE2-95A3-C3BE6B9BB5A3@mi crosoft.com...[color=green]
          > > Hi Pohihihi,
          > > on the line:
          > >
          > > bm.Save("C:\fil e.bmp",System.D rawing.Imaging. ImageFormat.Bmp );
          > >
          > > I believe that having a single \ will cause problems because \<char> is
          > > regarded as an escape character.
          > >
          > > Try:
          > > bm.Save(@"C:\fi le.bmp",System. Drawing.Imaging .ImageFormat.Bm p);
          > > which the @ means use the literal value of the string ignoring escape
          > > characters
          > >
          > > or
          > > bm.Save("C:\\fi le.bmp",System. Drawing.Imaging .ImageFormat.Bm p);
          > >
          > >
          > > Hope that helps.
          > > Mark
          > >
          > > "Pohihihi" wrote:
          > >[color=darkred]
          > >> I am getting a generic GDI+ error on following code. Basically it is
          > >> trying
          > >> to capture screen image and save in a file.
          > >> Is there a way to find more details on this error? Thanks for the help.
          > >>
          > >> ---------------------------
          > >> ERROR MSG
          > >> ---------------------------
          > >> System.Runtime. InteropServices .ExternalExcept ion: A generic error
          > >> occurred
          > >> in GDI+.
          > >> at System.Drawing. Image.Save(Stri ng filename, ImageCodecInfo encoder,
          > >> EncoderParamete rs encoderParams)
          > >> at System.Drawing. Image.Save(Stri ng filename, ImageFormat format)
          > >> at ScreenCapture.F orm1.TakeSnapNo w() in c:\visual studio
          > >> projects\screen capture\form1.c s:line 102
          > >>
          > >>
          > >>
          > >> Sorry for the formating below.
          > >>
          > >> //First, you need to import the BitBlt, GetDC and ReleaseDC functions.
          > >>
          > >> //imports the GDI BitBlt function that enables the background of the
          > >> window
          > >>
          > >> //to be captured
          > >>
          > >> [DllImport("gdi3 2.dll")]
          > >>
          > >> private static extern bool BitBlt(
          > >>
          > >> IntPtr hdcDest, // handle to destination DC
          > >>
          > >> int nXDest, // x-coord of destination upper-left corner
          > >>
          > >> int nYDest, // y-coord of destination upper-left corner
          > >>
          > >> int nWidth, // width of destination rectangle
          > >>
          > >> int nHeight, // height of destination rectangle
          > >>
          > >> IntPtr hdcSrc, // handle to source DC
          > >>
          > >> int nXSrc, // x-coordinate of source upper-left corner
          > >>
          > >> int nYSrc, // y-coordinate of source upper-left corner
          > >>
          > >> System.Int32 dwRop // raster operation code
          > >>
          > >> );
          > >>
          > >>
          > >> [DllImport("User 32.dll")]
          > >>
          > >> public extern static System.IntPtr GetDC(System.In tPtr hWnd);
          > >>
          > >> [DllImport("User 32.dll")]
          > >>
          > >> public extern static int ReleaseDC(Syste m.IntPtr hWnd, System.IntPtr
          > >> hDC);
          > >> //modified to include hWnd
          > >>
          > >>
          > >> //Now, to capture the screen in it's entirety you can do the following.
          > >>
          > >> public void TakeSnapNow()
          > >>
          > >> {
          > >>
          > >> System.IntPtr desktopDC=GetDC (System.IntPtr. Zero);
          > >>
          > >> Bitmap bm=new Bitmap(SystemIn formation.Virtu alScreen.Width,
          > >> SystemInformati on.VirtualScree n.Height);
          > >>
          > >> try
          > >>
          > >> {
          > >>
          > >> Graphics g=Graphics.From Image(bm);
          > >>
          > >> System.IntPtr bmDC=g.GetHdc() ;
          > >>
          > >> BitBlt(bmDC,0,0 ,bm.Width,bm.He ight,desktopDC, 0,0,0x00CC0020 /*SRCCOPY*/);
          > >>
          > >> bm.Save("C:\fil e.bmp",System.D rawing.Imaging. ImageFormat.Bmp );
          > >>
          > >> ReleaseDC(Syste m.IntPtr.Zero, desktopDC);
          > >>
          > >> g.ReleaseHdc(bm DC);
          > >>
          > >> g.Dispose();
          > >>
          > >> }
          > >>
          > >> catch(Exception er)
          > >>
          > >> {
          > >>
          > >> MessageBox.Show (er.ToString()) ;
          > >>
          > >> }
          > >>
          > >> }
          > >>
          > >>
          > >>
          > >>[/color][/color]
          >
          >
          >[/color]

          Comment

          • Pohihihi

            #6
            Re: GDI+ problem

            Thanks Mark, it is a nice start for me, I will dig more in interops on MSDN.


            "Mark R. Dawson" <MarkRDawson@di scussions.micro soft.com> wrote in message
            news:EFB6117F-9C66-4280-B0CE-A4543A3AF0FE@mi crosoft.com...[color=blue]
            > For looking what the exact error was through the interop services you can
            > get
            > the last error from the Win32 calls, although you cannot call the
            > GetLastError method directly, you must go through a method called
            > GetLastWin32Err or.
            >
            > Basically make sure you have imported the namespace
            > System.Runtime. InteropServices then when you import a DLL you need to set
            > the
            > SetLastError property to true i.e.
            >
            > [DllImport("gdi3 2.dll", SetLastError=tr ue)]
            >
            > Then when you have an exception you can do:
            >
            > intError = Marshal.GetLast Win32Error();
            >
            > which returns the error code.
            >
            > I am not an expert in this, but this might be enough to get you pointed in
            > the right direction.
            >
            > Hope that helps
            > Mark.
            >
            > "Pohihihi" wrote:
            >[color=green]
            >> Thanks Mark that was the real cause. I was looking all around to find the
            >> problem.
            >> I am still interested in learning how to trap errors while using
            >> interops.
            >>
            >>
            >> "Mark R. Dawson" <MarkRDawson@di scussions.micro soft.com> wrote in message
            >> news:5186DA9D-7726-4CE2-95A3-C3BE6B9BB5A3@mi crosoft.com...[color=darkred]
            >> > Hi Pohihihi,
            >> > on the line:
            >> >
            >> > bm.Save("C:\fil e.bmp",System.D rawing.Imaging. ImageFormat.Bmp );
            >> >
            >> > I believe that having a single \ will cause problems because \<char> is
            >> > regarded as an escape character.
            >> >
            >> > Try:
            >> > bm.Save(@"C:\fi le.bmp",System. Drawing.Imaging .ImageFormat.Bm p);
            >> > which the @ means use the literal value of the string ignoring escape
            >> > characters
            >> >
            >> > or
            >> > bm.Save("C:\\fi le.bmp",System. Drawing.Imaging .ImageFormat.Bm p);
            >> >
            >> >
            >> > Hope that helps.
            >> > Mark
            >> >
            >> > "Pohihihi" wrote:
            >> >
            >> >> I am getting a generic GDI+ error on following code. Basically it is
            >> >> trying
            >> >> to capture screen image and save in a file.
            >> >> Is there a way to find more details on this error? Thanks for the
            >> >> help.
            >> >>
            >> >> ---------------------------
            >> >> ERROR MSG
            >> >> ---------------------------
            >> >> System.Runtime. InteropServices .ExternalExcept ion: A generic error
            >> >> occurred
            >> >> in GDI+.
            >> >> at System.Drawing. Image.Save(Stri ng filename, ImageCodecInfo
            >> >> encoder,
            >> >> EncoderParamete rs encoderParams)
            >> >> at System.Drawing. Image.Save(Stri ng filename, ImageFormat format)
            >> >> at ScreenCapture.F orm1.TakeSnapNo w() in c:\visual studio
            >> >> projects\screen capture\form1.c s:line 102
            >> >>
            >> >>
            >> >>
            >> >> Sorry for the formating below.
            >> >>
            >> >> //First, you need to import the BitBlt, GetDC and ReleaseDC functions.
            >> >>
            >> >> //imports the GDI BitBlt function that enables the background of the
            >> >> window
            >> >>
            >> >> //to be captured
            >> >>
            >> >> [DllImport("gdi3 2.dll")]
            >> >>
            >> >> private static extern bool BitBlt(
            >> >>
            >> >> IntPtr hdcDest, // handle to destination DC
            >> >>
            >> >> int nXDest, // x-coord of destination upper-left corner
            >> >>
            >> >> int nYDest, // y-coord of destination upper-left corner
            >> >>
            >> >> int nWidth, // width of destination rectangle
            >> >>
            >> >> int nHeight, // height of destination rectangle
            >> >>
            >> >> IntPtr hdcSrc, // handle to source DC
            >> >>
            >> >> int nXSrc, // x-coordinate of source upper-left corner
            >> >>
            >> >> int nYSrc, // y-coordinate of source upper-left corner
            >> >>
            >> >> System.Int32 dwRop // raster operation code
            >> >>
            >> >> );
            >> >>
            >> >>
            >> >> [DllImport("User 32.dll")]
            >> >>
            >> >> public extern static System.IntPtr GetDC(System.In tPtr hWnd);
            >> >>
            >> >> [DllImport("User 32.dll")]
            >> >>
            >> >> public extern static int ReleaseDC(Syste m.IntPtr hWnd, System.IntPtr
            >> >> hDC);
            >> >> //modified to include hWnd
            >> >>
            >> >>
            >> >> //Now, to capture the screen in it's entirety you can do the
            >> >> following.
            >> >>
            >> >> public void TakeSnapNow()
            >> >>
            >> >> {
            >> >>
            >> >> System.IntPtr desktopDC=GetDC (System.IntPtr. Zero);
            >> >>
            >> >> Bitmap bm=new Bitmap(SystemIn formation.Virtu alScreen.Width,
            >> >> SystemInformati on.VirtualScree n.Height);
            >> >>
            >> >> try
            >> >>
            >> >> {
            >> >>
            >> >> Graphics g=Graphics.From Image(bm);
            >> >>
            >> >> System.IntPtr bmDC=g.GetHdc() ;
            >> >>
            >> >> BitBlt(bmDC,0,0 ,bm.Width,bm.He ight,desktopDC, 0,0,0x00CC0020
            >> >> /*SRCCOPY*/);
            >> >>
            >> >> bm.Save("C:\fil e.bmp",System.D rawing.Imaging. ImageFormat.Bmp );
            >> >>
            >> >> ReleaseDC(Syste m.IntPtr.Zero, desktopDC);
            >> >>
            >> >> g.ReleaseHdc(bm DC);
            >> >>
            >> >> g.Dispose();
            >> >>
            >> >> }
            >> >>
            >> >> catch(Exception er)
            >> >>
            >> >> {
            >> >>
            >> >> MessageBox.Show (er.ToString()) ;
            >> >>
            >> >> }
            >> >>
            >> >> }
            >> >>
            >> >>
            >> >>
            >> >>[/color]
            >>
            >>
            >>[/color][/color]


            Comment

            Working...