Click here to Skip to main content
14,695,321 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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);
Updated 19-Jan-13 10:33am

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900