Introduction to implementing the method of interacting with IE browser

Source: Internet
Author: User

1. Introduction

How to realize the operation of the object in IE browser is a very practical problem, through and IE-bound dll we can record IE browsed the page order, analysis of user behavior and patterns. We can filter the content of the Web page and translation, you can automatically fill in the page often need to fill in the form of the user, and so on, all of our example code is expressed through VC, the principle is to use the interface with IE objects to achieve access to IE. In fact, using COM technology, we know that COM is a language-independent binary object interaction pattern, so in fact we describe the following can be implemented in other languages, such as vb,delphi,c++ builder and so on.

2. IE Instance Traversal implementation

First, let's look at how the system knows how many instances of IE are currently running.

We know that under Windows architecture, an application can interact with instances of these applications through the operating system's running object table. However, the current implementation of IE is not registered in the running Object table, so other methods need to be adopted. We know that the Shellwindows collection can represent a collection of currently open windows that belong to the shell, and IE is an application that belongs to the shell.

Below we describe the use of VC to achieve the current IE instance of the traversal method. Ishellwindows is an interface to the system shell, and we can define an interface variable as follows:

Shdocvw::ishellwindowsptr M_spshwinds;

Then create an instance of the variable:

M_spshwinds.createinstance

(__uuidof (shdocvw::shellwindows));

Through the Ishellwindows interface method GetCount

You can get the number of current instances:

Long ncount = m_spshwinds->getcount ();

Method item through the Ishellwindows interface

You can get each instance object

Idispatchptr Spdisp;

_variant_t va (i, VT_I4);

Spdisp = M_spshwinds->item (VA);

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.