VC + + to achieve automatic closure of advertising window

Source: Internet
Author: User
Tags closure

First, the introduction

When we surf the internet, sometimes access to some Web pages will automatically pop up some ads window, and even a lot of personal home page in order to use online advertising to make money at the same time pop-up several or even more than 10 ads window. One of these windows is very troublesome to turn off, and if not, it will take up a lot of system resources, so many people detest this, as programmers can use their own technical advantages according to their actual needs to prepare some very suitable for their own gadgets. Therefore, this article on how to achieve the automatic closure of the advertising window through software programming, in order to be able to play the effect of the introduction.

Second, the program design idea and realization

First of all, analyze the general characteristics of the advertising window. Advertising windows are typically animated by JavaScript scripts or VBScript scripting languages on the home page, essentially an IE window. But most of the windows in the creation is not a menu, toolbars and other things, so we can first search IE window, and then determine whether the window has a menu and tool bar, and so on, if not to think it is advertising window, although such judgments are not very strict, But from the actual use of the situation, although some of the normal window may be mistakenly closed, but the probability of occurrence is rather small. can be completely ignored. And this happens more often in the chat room, so just before chatting it off, only when browsing the Web page running the program will generally not be misoperation.

The implementation of the program is not complicated, because the program to run up any time after the pop-up advertisement forms must be closed at any time, so you should set the timer, every once in a while to search for the following current advertising window, if there will be closed, otherwise continue to monitor. You can therefore start the timer with the SetTimer () function in the initialization entry function of the program. The following is the actual code to explain some of the key code:

Enumerates each window from the first window, and if the first window exists then you can search for the next window by GetWindow (Gw_hwndnext) in the while loop, and determine whether it is an ad form until the last form is searched:

CWnd* pMainWnd = AfxGetMainWnd()->GetWindow(GW_HWNDFIRST);
while (pMainWnd)
{
  ……
  pMainWnd = pMainWnd->GetWindow(GW_HWNDNEXT);
}

To determine whether the advertisement window, you can use the GetClassName () function to get the window type to determine whether the IE window:

CString strClassName;
GetClassName(pMainWnd->m_hWnd,strClassName.GetBufferSetLength(100),100);
For those not IE types of forms do not need to be considered, you can just get the strClassName window type and "Ieframe" for comparison to judge, if the IE window can be the next step of judgment://根据句柄获取子窗口指针
CWnd* pChildWnd=CWnd::FromHandle(FindWindowEx(pMainWnd->m_hWnd,NULL,"Worker",NULL));
if(!pChildWnd)
  pChildWnd=CWnd::FromHandle(FindWindowEx(pMainWnd->m_hWnd,NULL,"WorkerA",NULL));

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.