Automating Internet Explorer using C/C++

2019-07-03 16:55发布

I want to write a small utility which can automate internet explorer using C++ (No MFC). Some of the actions which i want to automate are :-
1. Opening a url
2. Clicking on a hyperlink in the browser instance
3. Setting the value of text boxes
4. Checking checkboxes, drop down menus etc.

I am an absolute beginner, and have no experience with COM, however i am currently in the process of learning. Can anyone guide me, like suggesting the resources and a breif outline of what i need to do to automate. I will really appreciate it.

Thanks, Ashish.

2条回答
放荡不羁爱自由
2楼-- · 2019-07-03 17:01

Jeremy Thompson suggested the basic answer: use a WebBrowser control. That's far easier in C#, because it includes quite some of the boilerplate code you need. Even MFC contains some of that. Without that, you'll need to implement a proper ActiveX container. For someone not knowing COM at all, this is highly non-trivial. ActiveX is an advanced COM technique. There's a bit of sample code here

Once you've hosted it, things become fairly trivial in comparison. Opening a URL is just a single call: IWebBrowser2::Navigate(URL, flags...)

查看更多
看我几分像从前
3楼-- · 2019-07-03 17:25

I strongly recommend the Microsoft Visual C++ compiler COM support.

Generally it works like this:

#import "c:\path\to\typelib.tlb"

#import "c:\path\to\library.dll"

#import "c:\path\to\program.exe"

This then makes it very easy to use Internet Explorer or any other COM object from C++.

See here for documentation:

查看更多
登录 后发表回答