|
Location: Desktop development - C/C++ License: The Intelliproject Open License (IPOL) Remote control PC's across a LAN part 2Posted by Silviu CarageaThis is a basic remote control application for Windows. |
Skill: AdvancedPosted: 22/04/2009Views: 1580Rating: 5.00 /5Popularity: 0.00 |
| Sign Up to vote for this article |
Remote Control it's a client-server application which allow users to remotely control another computer. It transmits the keyboard and mouse events from one computer to another, relaying the graphical screen updates back in the other direction, over a network.
This article represent a better version of the application described in this article. The application architecture has been radically changed and the CPU and memory usage was considerable reduced.
This application was written in c++ and compiled using Microsoft Visual Studio. NET 2003 , 2005 and 2008.
As technology has been used MFC (Microsoft Foundation Classes), API (Application Programming Interface), ATL (Active Template Library), COM (Component Object Model), + GDI (Graphical Device Interface +) and STL (Standard Template Library).
When it is started the server application launch two threads . In the first thread the application wait potential clients which will connect on port 5001.
Once connected each client runs in two new threads (one used to receive packages and one used to send packages). The server application has a "Client Manager" which retain a reference to each connected client.
The "Client Manager" is implemented in CClientsManager class.
This class has two private members . In m_arrClients container are retained references to each connected client . m_crtSection it's a CCriticalSection object used to synchronize the access of the class methods to m_arrClients container.
DWORD AddClient(CThread * client) - Add a client in m_arrClients .void RemoveClient(DWORD threadID) - Remove the client with the specified thread id.void RemoveAllClients() - Remove all clients from the serverDWORD GetClientsCount() - Return the connected clients countIn the other thread the server run a module which takes screen capture and save them in a memory share .From this memory share each connected client reads the images bytes which must be send over the network.

his module is implemented in CGrabSystemMessages class.
bool Init() - create the memory share and some events used to synchronize the read/write from/to memory share.void GrabWindowFrame() -Take a screenshot ,compress it in jpg and write it's bytes in the memory share. As shown above each connected client runs in two separated threads which allow to send /receive messages in the same time.
The thread which is used for client authentication and for sending the screen capture is implemented in CClientThread . The thread used for receiving the mouse and keyboard events is implemented in CClientThreadReceiveCommand class.
The user authentication it's made in plain text . As you can observe the application can be compiled without authentication module . All you must to do is to comment the #define USE_AUTHENTIFICATION line from stdafx.h
The image transfer is implemented in DoLoop . This thread wait until the reading from memory share can be done safely and after that read the frame buffer length and copy the frame bytes into a temporary buffer. After all this operations the informations are send over the network . In case any transmission error occur the client is disconnected from the server.
The informations about keyboard and mouse events are stored in the following structure:
struct evMSG
{
UINT uMsg; // WM_ mesaj
WPARAM wParam; // key indicators
LPARAM lParam ; // horizontal and vertical position
};
The viewer establish a connection to an address and port specified in "Options". When user press "Start" the application launch a new thread used to receive the screen captures from the server. The keyboard and mouse events are send in the main thread.
The keyboard and mouse events which are send to server are :
The viewer application support the following compiling feature:
WM_MOUSEMOVE (OnMouseMove) , the most generated message.This article, along with any associated source code and files, is licensed under The Intelliproject Open License (IPOL)
| Silviu Caragea
| Silviu Caragea is the Founder, Administrator and Chief Editor who wrote and runs The IntelliProject. He's been programming since 2000 and now he's student at The Faculty of Economic Cybernetics, Statistics and Informatics from Bucharest. In the same time he's working as software developer at Cratima Software, a Romanian software and web design company that activates both on the local and foreign market, providing its customers with software development services, internet and intranet solutions, web design, graphic design and IT consultancy. His programming experience includes: - C,C++, Visual C++(Win32 API, MFC, ADO, STL, DAO, ODBC, ATL, COM, DirectShow, DirectDraw, WTL) - Open Source libraries :CURL & Boost - HTML, CSS - Java (SE,ME) - JavaScript, Ajax, Google Web Toolkit (GWT) - Php, MySQL -Oracle, PL SQL - C# .NET -Objective C, IPhone SDK, Cocoa Location: |
Sign up to post message on the article message board!