Click here to Skip to main content
6,929,899 members and growing! (24,617 online)
Email Password   helpLost your password?
General Programming » Internet / Network » General     Intermediate License: The GNU General Public License (GPL)

Remote Control PCs

By Andy Bantly

Two projects that work together to remote control PCs across a LAN
C++ (VC6), Windows, MFC, Dev
Revision:14 (See All)
Posted:23 May 2000
Updated:17 Mar 2010
Views:153,954
Bookmarked:133 times
printPrint Friendly   add Share
      Discuss Discuss   Broken Article?Report  
85 votes for this article.
Popularity: 8.18 Rating: 4.24 out of 5
3 votes, 6.5%
1
1 vote, 2.2%
2
3 votes, 6.5%
3
4 votes, 8.7%
4
35 votes, 76.1%
5

Introduction

Here are two projects that work together to remote control PCs. This software only works for XP and above and is very stable. The server can handle multiple clients and each client can handle multiple connections to the same or different servers.

The projects are a server and client pair. The server is RDS, Remote Desktop Server, and the client is RDV, Remote Desktop Viewer. The executables are packaged up with the source code and there are projects for Visual Studio 2005 and 2008. I built a custom project out of the ZLIB library and compiled it as a windows library with the /MT settings. Both 32 and 64 bit library files, in release and debug mode, are included. The ZLIB.H and ZCONF.H files are also included. For examples of single-threaded usage, see the CZLib class. For examples of multi-threaded usage, see the classes CDriveMultiThreadedCompression, CMultiThreadedCompression, and CZLib.

The system can be broken into 4 main components:

  1. Network layer
  2. Compression layer
  3. Graphics layer
  4. Input layer

The network layer, CTCPSocket relies on SOCKET events as provided by the O/S and it then forwards them onto the message pump of the window that is expecting those messages. It has operator overloading, using << and >>, for sending and receiving data. The data is described by its own class in CPacket and each type of packet has a constructor. The socket class is derived from CAsyncSocket. This class relies on network events, as relayed through the message pump, to notify the program when something interesting happens. Of note, the send function is the “TransmitPackets” function. The “TransmitPackets” function transmits in-memory data or file data over a connected socket. The “TransmitPackets” function uses the operating system cache manager to retrieve file data, locking memory for the minimum time required to transmit and resulting in efficient, high-performance transmission.

The compression layer can be compartmentalized in 2 parts with 2 categories in each part. The outer part is the threading model. The compression can either be done in single or multiple threads. For each kind of threading, there are available the ZLIB compressor and my own homegrown arithmetic encoder compressor. Compression occurs in the data packet that represents the bitmap data. My compressor was based on the knowledge of Jean-Loup Gailley and Mark Nelson in their book “The Data Compression Book – Second Edition” ISBN 1-55851-434-1.

The graphics layer is another area that is multi-threaded. This portion of the code has undergone significant improvements since the last version of the code. The system is over twice as fast now with this reworking of this section of code. The main body of the code creates a thread for each rectangular region of the screen which will be polled for changes. When a thread detects a change in its area, it posts a notification back to the main thread. The main thread then sends this packet onto all the connected clients. Each thread has an activity timer. The less frequent a change occurs, the less frequent that area is checked. When a change does occur in an area, the activity timer is reset to the shortest pause.

The input layer is in the client code. The client captures the mouse and keyboard events and sends them to the server. The server uses the SendInput function to act out these events.

TODO

There are two areas of the code which still need attention. The first area is adding the capability to interact with terminal server sessions and capture those desktops. Currently, the code can't see those desktops. I am researching this problem diligently because it irritates me. The second area is to add support for the “DFMirage” mirror driver. This is the mirror driver that Tight VNC uses. I'm not reusing the VNC code, but I will learn how to instantiate a mirrored device context to help my code know better about screen updates.

History

  • 12th March, 2010
    • This update reworks the graphics layer and adds ZLIB compression to the compression layer. The compression layer supports both single and multi-threaded use of ZLIB and Arithmetic Encoding. Overall, the system was redesigned for a multi-threaded environment.
  • 20th October, 2009
    • This update adds MDI support to the system. The client component can now make multiple connections to many servers.
  • 17th October, 2009: Source code updated
    • The server now supports multiple monitor configurations. It captures the entire “virtual desktop”. Previously it only captured the primary desktop.
  • 9th October, 2009: Source code update that addresses three issues:
    • Binaries are added to the ZIP, in the Target Directory, for people to try out the system immediately
    • Receiving data is faster now
    • Experimental support for Video for Windows ICImageCompress and ICImageDecompress has been added
  • 14th September, 2009
    • Updated to use a multithreaded arithmetic encoder. It uses 4 threads to concurrently encode the DIB data. It previously was just single threaded. It improves compression by about 40%.
  • 12th March, 2010
    • The solutions are now available in VS 2005 and VS 2008 projects.
  • 16th March, 2010
    • Minor update that adds the ZLIB code to the project files

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPL)

About the Author

Andy Bantly


Member
Working as a software developer since 1989. Started out with Basic, FORTRAN and JCL, moved into Visual Basic 1.0, C, then C++, and now I work mainly in C++ using MFC, Win32, and ATL/COM. I use Microsoft Products only because that is what gives me gainful employment. Through work, I have a lot of experience with HTML, JavaScript, XSL transformations, the XMLHTTP object, PHP 4.x, and simple COM object integrations.

I've worked for the University of Oklahoma in the school of meteorology (Go SOONERS!), consulting, and now as a Senior Software Engineer. These things keep my lights on and electricity going. My dream job is to own a bowling alley and rub elbows with pro-bowlers!

I've had a number of computers through the years, some that I wish I still had. The love of programming started on a friends TI-99 4a in 1982. From there I worked through Commodore (VIC-20, 64, Amiga 500). After the Amiga I went without a PC for a long time. I just worked on the one at the office. Around 2000, when XP came out, I assembled, from components, my first PC. I got bitten by the need to constantly upgrade the Motherboard, BIOS, CPU, RAM, and VGA cards. When AGP was discontinued, I discontinued that addiction and still have that machine and work from it from time to time. Who knows how many thousands of wasted dollars were dropped into that box.

I now am using a beefed up Compaq Presario F700 to do most of my work. It has been upgraded to use a 64bit 2.0 GHz CPU, 7200 RPM 320GB HDD, and 4GB of RAM. My main studio of choice is VS2005.

I will upgrade it whenever 2010 is finally out and stable. My upgrade path involves taking a night course at a junior college so that I can get all the free MS swag that the professors give you in order to complete the course work.
(This is how I have my current 2005 professional edition)

Please check out http://www.quickbiblesoftware.com
Occupation: Founder
Company: GravyLabs LLC
Location: United States United States

Other popular Internet / Network articles:

Article Top
 
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 65 (Total in Forum: 65) (Refresh)FirstPrevNext
GeneralMy vote of 2 PinmemberJohnny J.21hrs 21mins ago 
GeneralLinker warnings during compilation PinmemberAndy Bantly5:38 16 Mar '10  
GeneralRe: Linker warnings during compilation PinmemberAndy Bantly13:13 17 Mar '10  
GeneralUpdate to the article PinmemberAndy Bantly11:52 5 Oct '09  
GeneralRe: Update to the article Pinmemberaspdotnetdev13:43 14 Oct '09  
CodeProject wrote:
We're Sorry, but the article you are trying to view was deleted at 7 Oct 2009.

I get that when I click that link.

Visual Studio is an excellent GUIIDE.

GeneralRe: Update to the article PinmemberAndy Bantly18:36 14 Oct '09  
GeneralRe: Update to the article Pinmemberaspdotnetdev18:39 14 Oct '09  
GeneralModern Update to the Remote Control System Pinmemberandybantly5:36 4 Oct '09  
GeneralRe: Modern Update to the Remote Control System PinmemberHari Om Prakash Sharma20:12 15 Oct '09  
GeneralRe: Modern Update to the Remote Control System PinmemberAndy Bantly3:07 16 Oct '09  
GeneralMy vote of 1 Pinmembergzlonghair0:40 25 May '09  
QuestionHow to apply IME...? Pinmemberlayus23:19 22 Apr '09  
General[Message Deleted] Pinmemberit.ragester23:00 2 Apr '09  
Generalthank you for Andy Bantly Pinmemberhenry369522:22 18 Nov '08  
GeneralDoes it work on XP ? Pinmembergndnet17:39 20 Apr '08  
GeneralRe: Does it work on XP ? Pinmemberwyb28725:44 8 Jun '08  
GeneralRe: Does it work on XP ? Pinmemberhenry369522:16 18 Nov '08  
Questionhow to get copy file from another node..? PinmemberKhathar1:36 7 May '07  
GeneralReally amazing! Can you give me a copy of the project comment document? PinmemberSuperChen111120:36 30 Jan '07  
GeneralRe: Really amazing! Can you give me a copy of the project comment document? Pinmemberhenry369522:18 18 Nov '08  
QuestionRemote PC Pinmemberhan qiao16:20 17 Jan '07  
QuestionDll Convert PinmemberCode_Warrior3:56 4 Dec '06  
Generalshouldn't this be in the Free Tools section? PinmemberMihai Moga2:02 17 Apr '06  
GeneralCan anyone help me? PinmemberPetiao15:56 23 Feb '06  
Generalthx for sharing!! PinmemberPetiao16:18 22 Feb '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

PermaLink | Privacy | Terms of Use
Last Updated: 17 Mar 2010
Editor: Deeksha Shenoy
Copyright 2000 by Andy Bantly
Everything else Copyright © CodeProject, 1999-2010
Web19 | Advertise on the Code Project