Click here to Skip to main content
15,112,304 members
Articles / Programming Languages / XML
Posted 15 Sep 2009


43 bookmarked

Screen Cast Server

Rate me:
Please Sign up or sign in to vote.
4.84/5 (16 votes)
15 Sep 2009CPOL2 min read
A screen cast server with client



Ever wanted to see what is on someone else's screen but you didn't want to install PC Anywhere or Configure VNC?

Well now, it's possible to just run the Screen Cast Server and view that person's screen from your Screen Cast Client.

Warning: This code is not optimized for Internet usage and does not imply that it is better than PC Anywhere, VNC, or any other 3rd party application on the market. It is also not encrypted in any way and is thus not secure.


I am constantly bugged by end users that say "I did click the right button" or "I did select that first". I decided that I want to see what they see when they use my apps, so I developed this simple little Client - Server screen casting utility. The server part is so small you can copy paste it into any of your apps and call it when that app loads.

Using the Code

Using this code is simple if you know a little bit of Remoting.

The server part uses Remoting to open a port and exposes the CastScreen method:

ScreenHost.ScreenObject remoteObject = new ScreenHost.ScreenObject();

//************************************* TCP *************************************//
// using TCP protocol

TcpChannel channel = new TcpChannel(8082);

ChannelServices.RegisterChannel(channel, false);

                      "CastScreen", WellKnownObjectMode.SingleCall);

//************************************* TCP *************************************//

The exposed method (CastScreen) resides in a shared class that is used by both the client and the server:

public MemoryStream CastScreen(int formatType)
  //Get the Screen Bounds
  Rectangle bounds = Screen.GetBounds(Screen.GetBounds(Point.Empty));

  //Switching here to get formatType into imgFormat
  using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
      using (Graphics g = Graphics.FromImage(bitmap))
         g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);

      //Convert the Image to a the given format
      MemoryStream ms = new MemoryStream();
      bitmap.Save(ms, imgFormat);
      return ms;

The client application has a timer that acts as the refresh rate and it makes a BackGroundWorker run the code to get the image from the server.

//Setup the Host Instance

   hostInstance = 
      "tcp://" + hostIP + ":8082/CastScreen", null);
   if (hostInstance != null)
      ms = hostInstance.CastScreen(imgFormat);
      img = Image.FromStream(ms);
      updatePictureBox(picCast, img);
      updateText(lblMessage, "Screen Updated - " + DateTime.Now);
catch (Exception exc)
   if (bgWorker1.IsBusy)
   { bgWorker1.CancelAsync(); }
   updateText(lblMessage, exc.Message);

Points of interest

The best thing about this is that there are so many applications for this and it can be embedded into any of your applications. If you want, you can give the user the option of clicking a button first to start the server or you can make it fire when the form loads.


This is version one of this app. If anyone wants to upgrade it, please go ahead. Just keep me in the loop and send me a copy.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Pieter Alec Myburgh
Software Developer (Senior) EOH Microsoft Coastal
South Africa South Africa
Senior Software Engineer & Team Lead.

I reject your code and substitute my own!

Comments and Discussions

BugThink it has a memory leek Pin
Andy Wyatt225-Aug-14 1:41
MemberAndy Wyatt225-Aug-14 1:41 
AnswerRe: Think it has a memory leek Pin
Andy Wyatt225-Aug-14 2:46
MemberAndy Wyatt225-Aug-14 2:46 
GeneralMy vote of 1 Pin
Dave Kreskowiak16-Sep-09 4:58
mveDave Kreskowiak16-Sep-09 4:58 
GeneralRe: My vote of 1 Pin
ozkan.pakdil17-Sep-09 1:53
Memberozkan.pakdil17-Sep-09 1:53 
GeneralRe: My vote of 1 Pin
cwp4223-Sep-09 23:48
Membercwp4223-Sep-09 23:48 
GeneralSo Awesome Pin
Xmen Real 15-Sep-09 8:38
professional Xmen Real 15-Sep-09 8:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.