Watch the screen...

m7j4p7

Regular
Joined
Nov 16, 2003
Messages
54
Hi,

Our Network Admins like to be able to see what students are doing whilst they are logged on. Using vb, can I write a program which will allow the Admins to be able to view on their screens what the student is viewing on theirs.

I.E. The student opens Word and types 'Hello World.'

At the same time, I want an Admin to be able to open a window which looks like the students. - Word opened with 'Hello World'.

Do you get what I mean? The Admin is monitoring the student by seeing exactly what they see from their terminal?

Sorry for more long-windedness (see some of my other posts!)

Thanks,
 
You can use APIs to take a screenshot and then send it using a socket to the "Admin" computer. The APIs you'll need are:
Visual Basic:
Declare Function GetDesktopWindow Lib "user32.dll" () As IntPtr
Declare Function GetDC Lib "user32.dll" (ByVal hwnd As IntPtr) As IntPtr
Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal hdc As IntPtr) As Int32
Declare Function BitBlt Lib "gdi32.dll" (ByVal hDestDC As IntPtr, ByVal x As Int32, ByVal y As Int32, _
 ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal hSrcDC As IntPtr, ByVal xSrc As Int32, _
  ByVal ySrc As Int32, ByVal dwRop As Int32) As Int32
I haven't got a working code sample at the moment, I can make one if you need it
 
To get the screenshot using the APIs:
Visual Basic:
Public Function GetDesktopScreenshot() As Bitmap
Dim Desk, DeskDC, BitmapDC As IntPtr
Dim Pic As Bitmap, PicDraw As Graphics

'Make a Bitmap the same size as the screen
Pic = New Bitmap(Screen.Bounds.Width, Screen.Bounds.Height, PixelFormat.Format16bppRgb565)
PicDraw = Graphics.FromImage(Pic) 'Get a Graphics Object
BitmapDC = PicDraw.GetHdc() 'Get a hDC from the Graphics Object

Desk = GetDesktopWindow() 'Get the desktop hWnd
DeskDC = GetDC(Desk) 'Get a hDC for the desktop

'Copy the desktop to the picture
BitBlt(BitmapDC, 0, 0, Screen.Bounds.Width, Screen.Bounds.Height, DeskDC, 0, 0, &HCC0020)

ReleaseDC Desk, DeskDC 'Release the Desktop hDC

PicDraw.ReleaseDC(BitmapDC) 'Release the Bitmap hDC
PicDraw.Dispose() 'Dispose the Graphic object

Return Pic
End Function
The above code isn't tested so tell me if there doesn't work.

The easiest way to send the picture would be to save it and read it in again as a string, but it uses less resources and can be reassembled faster at the other end if you just lock it and read the bitmap data in raw and send it.
 
Good point! I would like, however, to integrate this with some other bits and pieces I am writing. However, the source of VNC might give me some starting points! ;)
 
Back
Top