Display the desktop of a remote computer regularly

Source: Internet
Author: User

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);
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.