关于Windows 7屏幕截图的问题。 [英] Question regards to the Windows 7 screen capture.

查看:121
本文介绍了关于Windows 7屏幕截图的问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

游戏开发。我们在捕获部分有问题。

Windows 7操作系统。进程nprotect'的gamemon.des屏幕捕获功能不起作用。我出错的部分是什么?



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);
            try
            {
                bitmap = Image.FromHbitmap(GetCurrentObject(dC, 7));
            }
            finally
            {
                ReleaseDC(desktopWindow, dC);
            }
            return bitmap;
        }

        [DllImport("gdi32.dll")]
        private static extern IntPtr GetCurrentObject(IntPtr hdc, ushort objectType);
        [DllImport("user32.dll")]
        private static extern IntPtr GetDC(IntPtr hwnd);
        [DllImport("User32")]
        private static extern IntPtr GetDesktopWindow();
        [DllImport("user32.dll")]
        private static extern void ReleaseDC(IntPtr hwnd, IntPtr hdc);
    }
}

推荐答案

实际上.net有自己的方法来执行此操作: Graphics.CopyFromScreen [ ^ ]。我建议你参考这篇简单的文章来实现示例: TeboScreen:Basic C#Screen Capture Application [ ^ ]
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[^]


ZoltánZörgő回答。没有进展,但是说了

还有其他方法吗?
Zoltán Zörgő answer.Does not progress, but having said
Is there any other way?


这篇关于关于Windows 7屏幕截图的问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆