Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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...
Posted

Maybe Screen Capture in WPF & WinForms Application[^] can help you get started.
 
Share this answer
 
Comments
Tarun.K.S 6-May-11 3:39am    
Good link, bookmarked for future reference :) 5+
Abhinav S 6-May-11 9:41am    
Thanks.
Sergey Alexandrovich Kryukov 6-May-11 9:56am    
So, I added my Solution with the options of the server side and WPF imagine. There is also an option to simply use Web browser on client (teacher's side).

Please see.
--SA
Sergey Alexandrovich Kryukov 6-May-11 9:37am    
Can be useful, my 5. Also needs remoting.
--SA
Abhinav S 6-May-11 9:41am    
Thank you
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
 
Share this answer
 
While sniffing around I found
C#
[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;
}


C#
[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,
C#
//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 Class[^]
The trick is/was there is always a share per logical drive or each machine like "\\machine\\c$" which you can exploit as administrator. Rest is copy an application run it there to capture info and retrieve it back.
Edit:
Use this to release network resource.
C#
[DllImport("mpr.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private static extern int WNetCancelConnection2A (
    [MarshalAs (UnmanagedType.LPStr)]
    string lpName
    , int dwFlags
    , int fForce
    );
 
Share this answer
 
v3

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