Click here to Skip to main content
11,928,985 members (47,998 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#2.0 C#
And game development. We have a problem in the capture part.
Windows 7 operating system. the process nprotect's gamemon.des the screen capture function does not work. What part did I go wrong?

namespace System.Drawing
    using System;
    using System.Runtime.InteropServices;
    public static class ScreenCapture
        public static Bitmap DesktopCapture()
            Bitmap bitmap;
            IntPtr desktopWindow = GetDesktopWindow();
            IntPtr dC = GetDC(desktopWindow);
                bitmap = Image.FromHbitmap(GetCurrentObject(dC, 7));
                ReleaseDC(desktopWindow, dC);
            return bitmap;
        private static extern IntPtr GetCurrentObject(IntPtr hdc, ushort objectType);
        private static extern IntPtr GetDC(IntPtr hwnd);
        private static extern IntPtr GetDesktopWindow();
        private static extern void ReleaseDC(IntPtr hwnd, IntPtr hdc);
Posted 19-Jan-13 10:14am
Edited 19-Jan-13 10:33am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Actually .net has it's own method to do it: Graphics.CopyFromScreen[^]. I suggest you consult this simple article for sample implementation: TeboScreen: Basic C# Screen Capture Application[^]
Sergey Alexandrovich Kryukov 19-Jan-13 18:47pm
Absolutely right, my 5.

Sorry, my mistake was to put a bit redundant answer, as I did it before I paid attention that you already advised to use CopyFromScreen. However, in return, I added some motivation information, please see. I will add a credit to your answer now.

Zoltán Zörgő 20-Jan-13 2:22am
Thank you.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Zoltán Zörgő answer.Does not progress, but having said
Is there any other way?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100