How to control instance of IExplorer from C++ app ?

How to control instance of IExplorer from C++ app ?

Post by Alexander Arlievsk » Sun, 14 Nov 1999 04:00:00



Hi,
I want to execute and control Internet explorer from my program.
In the help for IWebBrowser2 :
This interface enables applications to implement an instance of the
WebBrowser control (ActiveX? control) or control an instance of the
Microsoft? Internet Explorer application (OLE Automation).

So can you tell me how can I create new instance of Microsoft? Internet
Explorer and
control it ?
--
==============================================================================
        Alexander Arlievsky

==============================================================================

 
 
 

How to control instance of IExplorer from C++ app ?

Post by Ziv Cas » Mon, 15 Nov 1999 04:00:00


On Sat, 13 Nov 1999 18:29:08 +0200, Alexander Arlievsky


>Hi,

Hi Alex. Long time no speak.

Quote:>I want to execute and control Internet explorer from my program.
>In the help for IWebBrowser2 :
>This interface enables applications to implement an instance of the
>WebBrowser control (ActiveX? control) or control an instance of the
>Microsoft? Internet Explorer application (OLE Automation).

>So can you tell me how can I create new instance of Microsoft? Internet
>Explorer and
>control it ?

You should be aware that there are two possibilities:

1. To start IE as a standalone program, and pass commands to it.
  IE supports a DDE interface (an issue which was discussed in
  this group a while back).

2. To embed the WebBrowser control in your application (say,
  as an ActiveX control in a dialog box).

Which are you referring to?

---------------------------------------------
Ziv Caspi


 
 
 

How to control instance of IExplorer from C++ app ?

Post by Alexander Arlievsk » Mon, 15 Nov 1999 04:00:00



> On Sat, 13 Nov 1999 18:29:08 +0200, Alexander Arlievsky

> >Hi,

> Hi Alex. Long time no speak.

> >I want to execute and control Internet explorer from my program.
> >In the help for IWebBrowser2 :
> >This interface enables applications to implement an instance of the
> >WebBrowser control (ActiveX? control) or control an instance of the
> >Microsoft? Internet Explorer application (OLE Automation).

> >So can you tell me how can I create new instance of Microsoft? Internet
> >Explorer and
> >control it ?

> You should be aware that there are two possibilities:

> 1. To start IE as a standalone program, and pass commands to it.
>   IE supports a DDE interface (an issue which was discussed in
>   this group a while back).

That's what I need, and now there is much more advanced way to do it -
COM.
I mastered it myself:
The following code will start explorer 4 or 5, and load MSoft web page.

        #include "mshtml.h"

        CoInitialize(NULL);
        CString progid = "InternetExplorer.Application.1";
        BSTR ole_progid = progid.AllocSysString();

        CLSID clsid;
        CLSIDFromProgID(ole_progid,&clsid);
        ::SysFreeString(ole_progid);

        IWebBrowser2 *pBrowser;

        CoCreateInstance(clsid,NULL,CLSCTX_LOCAL_SERVER,IID_IWebBrowser2,(void
**)&pBrowser);

        CString url = "http://www.microsoft.com";
        BSTR ole_url = url.AllocSysString();

        COleVariant empty;

        pBrowser->put_Visible(TRUE);
        pBrowser->Navigate(ole_url,&empty,&empty,&empty,&empty);

        ::SysFreeString(ole_url);
        pBrowser->Release();

Quote:> 2. To embed the WebBrowser control in your application (say,
>   as an ActiveX control in a dialog box).

That's easy, MFC does it for you automatically.

> Which are you referring to?

> ---------------------------------------------
> Ziv Caspi


--
==============================================================================
        Alexander Arlievsky
        CS, Technion.

        http://tochna.technion.ac.il/~sasha
        Phone: 054-999948

  Visual C++ MFC developer,
  ER-Vision Ltd.
  Israel.

"The most valuable tool for debugging are brains".

==============================================================================

 
 
 

How to control instance of IExplorer from C++ app ?

Post by Lee Gree » Thu, 18 Nov 1999 04:00:00


I'm trying to do the same thing in my app, and have tried experimenting with
your example also.  Both versions leave
"IE residue" on NT 4.0 which can be verfied using NT Task
Manager.  Yep, IE goes away under the Apps tab, but
for an eye opener look in the Process tab and you will
see IEXPLORER and it will not go away unless you
kill it through task manager.  If you happened to have IE
up already before looking at this, close it (and any other
instances), kill IEXPLORER in Task Manager, and run
your example again.  I've talked to several folks more
knowledgable than me and they say there is nothing
incorrect with my code (nor yours since it is almost exactly
like mine)

I know this to be correct for IE 4 with SP 2.  Specifically
version 4.04.72.3612.1713.  I've seen it on 2 different
machines.  However I tried it on an earlier version of IE 4.0
(4.0.4.72.2106.8), and there was NO "residue".  I'm updating
that machine with the new version to see if there is an
"undocumented feature" with later versions of IE.



>> On Sat, 13 Nov 1999 18:29:08 +0200, Alexander Arlievsky

>> >Hi,

>> Hi Alex. Long time no speak.

>> >I want to execute and control Internet explorer from my program.
>> >In the help for IWebBrowser2 :
>> >This interface enables applications to implement an instance of the
>> >WebBrowser control (ActiveX? control) or control an instance of the
>> >Microsoft? Internet Explorer application (OLE Automation).

>> >So can you tell me how can I create new instance of Microsoft? Internet
>> >Explorer and
>> >control it ?

>> You should be aware that there are two possibilities:

>> 1. To start IE as a standalone program, and pass commands to it.
>>   IE supports a DDE interface (an issue which was discussed in
>>   this group a while back).

>That's what I need, and now there is much more advanced way to do it -
>COM.
>I mastered it myself:
>The following code will start explorer 4 or 5, and load MSoft web page.

> #include "mshtml.h"

> CoInitialize(NULL);
> CString progid = "InternetExplorer.Application.1";
> BSTR ole_progid = progid.AllocSysString();

> CLSID clsid;
> CLSIDFromProgID(ole_progid,&clsid);
> ::SysFreeString(ole_progid);

> IWebBrowser2 *pBrowser;

> CoCreateInstance(clsid,NULL,CLSCTX_LOCAL_SERVER,IID_IWebBrowser2,(void
>**)&pBrowser);

> CString url = "http://www.microsoft.com";
> BSTR ole_url = url.AllocSysString();

> COleVariant empty;

> pBrowser->put_Visible(TRUE);
> pBrowser->Navigate(ole_url,&empty,&empty,&empty,&empty);

> ::SysFreeString(ole_url);
> pBrowser->Release();

>> 2. To embed the WebBrowser control in your application (say,
>>   as an ActiveX control in a dialog box).

>That's easy, MFC does it for you automatically.
>> Which are you referring to?

>> ---------------------------------------------
>> Ziv Caspi

>--
>===========================================================================
===
>        Alexander Arlievsky
>        CS, Technion.

>        http://tochna.technion.ac.il/~sasha
> Phone: 054-999948

>  Visual C++ MFC developer,
>  ER-Vision Ltd.
>  Israel.

>"The most valuable tool for debugging are brains".

>===========================================================================

===