Remote Display For Windows Mobile 5 or above

Download the source code

As I already posted here, ActiveSync IP address can be used to create socket based application. Here is an application that makes use of this; this application displays the Windows Mobile desktop on a remote computer. You can also take the screen shots. The screen can be saved to JPEG or PNG files, these are the only supported picture formats now. But you can extent this by creating an output plug-in DLL.

There are two components in this application, Mobile Server which runs on the mobile device and Client Component which runs on the PC. The mobile server listens on port 8082 which is configurable. The client application connects to this server.

When connected to the mobile server, client application sends MS_CMD_SCREENSHOT command every 100 milliseconds and receives the screen data in compressed form. The client uncompresses the data and displays it on the screen. The mobile server application received commands from the client and based on the command it receives sends the data to the client. As of now the only command supported is MS_CMD_SCREENSHOT which sends the screen data. The command structure is defined as

typedef struct __MS_CMD_TAG__
int nCommand;
int nDataSize;

The nCommand member specifies the command and nDataSize member specifies the size of additional data in bytes. This member is reserved for future use and is not used now.

The screen data format is:

typedef struct __MS_SCREEN_DATA_TAG__
int nWidth;
int nHeight;
int nBPP;
int nLineWidth;
int nCompressedSize;
int nDataSize;

The nWidth, nHeight members are width and height of the screen data respectively. The nBPP member is the bits-per-pixel of the screen data. The nLineWidth member is the length of the scan line of the screen data. nCompressedSize represents the compressed data. nDataSize is the uncompressed size.

The compressed data is send after the sending the MS_SCREEN_DATA structure, so the total size of the data will be nCompressedData + sizeof(MS_SCREEN_DATA).

The client application uses Output Plug-in for saving the screen shots. There are two output plug-in now, JPEG plug-in and PNG plug-in. You can extend this by creating Output Plug-in. The plug-in exports only one function GetPluginInterface which returns a pointer to IOutputPlugin which is defined as:

class COutputPlugin
virtual LPCTSTR GetFileName() = 0;
virtual LPCTSTR GetPluginName() = 0;
virtual LPCTSTR GetDescription() = 0;
virtual long GetVersion() = 0;
virtual LPCTSTR GetFilterString() = 0;
virtual LPCTSTR GetExtension() = 0;

virtual int SaveImage(const char* lpszFile,BITMAPINFO* pInfo,BYTE* pBytes) = 0;
virtual void Release() = 0;

typedef COutputPlugin IOutputPlugin;

The class is simply and self-explanatory.

The application works well on my HTC TyTN II mobile and is not tested on any other mobile. Also this application will not work with the Emulator.

Leave a Reply

Your email address will not be published. Required fields are marked *