WPF中的远程屏幕捕获 [英] Remote Screen Capture in WPF

查看:80
本文介绍了WPF中的远程屏幕捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在WPF中创建一个应用程序,其中一名老师是本地的主要主持人,她通过LAN与30位学生连接..
老师想通过他/她的IP地址捕获学生屏幕..
无论学生在计算机上做什么,老师都可以捕获屏幕并将其保存在PC上(通过LAN)...
没有可用的Internet连接...
请帮我...并给我适当的链接...在WPF中,仅C#
提前感谢...

I am creating one application in WPF, where a teacher is the main local host and she is connected to 30 students through LAN..
The teacher wants to capture a Students Screen through his/her IP Address..
Whatever the student is doing on his/her Computer, the teacher can capture a screen and save it on her PC (through LAN)...
There is No Internet Connection is available...
Plz help me out...and give me proper link...in WPF,C# only
Thanx in Advance...

推荐答案

也许 ^ ]可以帮助您入门.
Maybe Screen Capture in WPF & WinForms Application[^] can help you get started.


要正确执行此操作,您应该使Windows Service在每位学生的计算机上运行. Abhinav已经提供了有关如何捕获屏幕的文章的参考.您的Windows服务应按客户端的网络要求捕获屏幕.客户端应该正在运行教师的计算机.实现此类请求/响应客户端/服务器模型的最简单方法是使用服务合同自托管(在Windows Service上)WCF.

如果您不想使用WCF(强烈建议使用WCF),则可以使用从原始套接字开始的任何级别,但是您需要使用TCP.
请参阅我过去关于该主题的答案:
如何将byte []发送到另一台PC [ ^ ],
在局域网上与两个Windows应用程序进行通信. [ ^ ].

如果性能不是问题(很可能不是问题),那么实现仅具有一个响应的基本专用HTTP服务器也非常方便:以PNG文件的形式提供屏幕截图.这很方便,因为您可以使用一种可用的Web浏览器代替WPF客户端.该请求将为http://[student_ip]:[port]/screep.png.使用WPF也很方便:您可以使用从Uri构造的System.Windows.Media.Imaging.BitmapImage.
参见:
http://msdn.microsoft.com /en-us/library/system.windows.media.imaging.bitmapimage(v=vs.96).aspx [ http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.aspx [ ^ ](请参阅随附的代码示例).

—SA
To do it properly, you should make a Windows Service running on each student''s computer. Abhinav already provided the reference to the article on how to capture screen. You Windows Service should capture screen on client''s request by network. The client should be running of the teacher''s computer. The simplest way to implement such request/response client/server model is the self-hosted (on the Windows Service) WCF using Service Contract.

If you don''t want to use WCF (which I highly recommend), you can use any level starting from raw sockets, but you need to use TCP.
See my past answer on this topic:
how i can send byte[] to other pc[^],
Communication b/w two Windows applications on LAN.[^].

If performance is not an issue (most likely it is not), it''s also very convenient to implement a rudimentary specialized HTTP server with only one response: delivering a screen capture in the form of PNG file. This is convenient, because instead your WPF client you can use one of the available Web browser. The request would be http://[student_ip]:[port]/screep.png. It is also convenient with WPF: you could use System.Windows.Media.Imaging.BitmapImage constructed from Uri.
See:
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage(v=vs.96).aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.aspx[^] (see the code sample included).

—SA


我在四处嗅探时发现了
While sniffing around I found
[StructLayout (LayoutKind.Sequential)]
    public struct NETRESOURCE
{
    public int dwScope;
    public int dwType;
    public int dwDisplayType;
    public int dwUsage;
    [MarshalAs (UnmanagedType.LPStr)]
    public string lpLocalName;
    [MarshalAs (UnmanagedType.LPStr)]
    public string lpRemoteName;
    [MarshalAs (UnmanagedType.LPStr)]
    public string lpComment;
    [MarshalAs (UnmanagedType.LPStr)]
    public string lpProvider;
}





[DllImport("mpr.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private static extern int WNetAddConnection2A (
    [MarshalAs (UnmanagedType.LPArray)]
    NETRESOURCE [] lpNetResource,
    [MarshalAs (UnmanagedType.LPStr)]
    string lpPassword,
    [MarshalAs (UnmanagedType.LPStr)]
    string lpUserName,
    int dwFlags
    );


您可以做的是


What you can do with this is,

//Connect a remote share with impersonation
ConnectAs (string pShare, string pDomain, string pUser, string pPwd)
{
int err = 0;
string sUser = pDomain + @"\" + pUser;
int dwFlags = 0;
NETRESOURCE [] nr = new NETRESOURCE [1];
nr[0].lpRemoteName = pShare;
nr[0].lpLocalName = "";  
nr[0].dwType = 1;     //disk
nr[0].dwDisplayType = 0;
nr[0].dwScope = 0;
nr[0].dwUsage = 0;
nr[0].lpComment = "";
nr[0].lpProvider = "";
err = WNetAddConnection2A (nr, pPwd, sUser, dwFlags);
if (err != 0)
    throw new Exception ("Unable to connect to " + pShare
        + ".  Error=" + err.ToString());
//Utilize System.IO.File functions to copy whatever you like
//Utilize WMI class Win32_process to run whatever you like
//Again with IO stuff retrieve whatever you like.


MSDN Win32_Process类 [


MSDN Win32_Process Class[^]
The trick is/was there is always a share per logical drive or each machine like "\\machine\\c


这篇关于WPF中的远程屏幕捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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