Discussion:
Internet Explorer COM using pure C++
(too old to reply)
Honsik
2007-04-11 18:23:58 UTC
Permalink
I want to know, how can I easily make an object of IE and make it
visible same like I open it from my desktop. I want to set http adress
and using the objects on that page, for example cliking on button or
hypertexts. All only in C++.

I am beginner and I am using only pure C++. That mean win32
application without .NET, ATL, MFC. I have Visual Studio 2005.

In Visual Foxpro I can do only this commands:
loObj = CreateObject("InternetExplorer.Application")
loObj.Visible = .T.
loObj.Navigate2("www.google.com")

I want something like this but in C++.
Can somebody help me ?
Brian Muth
2007-04-11 21:00:27 UTC
Permalink
Post by Honsik
I want to know, how can I easily make an object of IE and make it
visible same like I open it from my desktop. I want to set http adress
and using the objects on that page, for example cliking on button or
hypertexts. All only in C++.
I am beginner and I am using only pure C++. That mean win32
application without .NET, ATL, MFC. I have Visual Studio 2005.
loObj = CreateObject("InternetExplorer.Application")
loObj.Visible = .T.
loObj.Navigate2("www.google.com")
I want something like this but in C++.
Can somebody help me ?
This will get you started:
#include "stdafx.h"
#import "C:\WINDOWS\system32\ieframe.dll" no_namespace

int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr;
CoInitialize (0);

try
{
IWebBrowser2Ptr p;

hr = p.CreateInstance (__uuidof (InternetExplorer));
if (SUCCEEDED (hr))
{
p->Visible = true;
CComVariant v (www.google.com);
p->Navigate2 (&v);
}
}
catch (_com_error e)
{
// Examine e.Message ()
}

CoUninitialize ();
return 0;
}



Brian
Honsik
2007-04-13 12:41:40 UTC
Permalink
Post by Brian Muth
Post by Honsik
I want to know, how can I easily make an object of IE and make it
visible same like I open it from my desktop. I want to set http adress
and using the objects on that page, for example cliking on button or
hypertexts. All only in C++.
I am beginner and I am using only pure C++. That mean win32
application without .NET, ATL, MFC. I have Visual Studio 2005.
loObj = CreateObject("InternetExplorer.Application")
loObj.Visible = .T.
loObj.Navigate2("www.google.com")
I want something like this but in C++.
Can somebody help me ?
#include "stdafx.h"
#import "C:\WINDOWS\system32\ieframe.dll" no_namespace
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr;
CoInitialize (0);
try
{
IWebBrowser2Ptr p;
hr = p.CreateInstance (__uuidof (InternetExplorer));
if (SUCCEEDED (hr))
{
p->Visible = true;
CComVariant v (www.google.com);
p->Navigate2 (&v);
}
}
catch (_com_error e)
{
// Examine e.Message ()
}
CoUninitialize ();
return 0;
}
Brian
Thanks Brian, It is OK, but how can I simulate button click in IE page
for example www.google.com
Brian Muth
2007-04-13 17:42:41 UTC
Permalink
Post by Honsik
Thanks Brian, It is OK, but how can I simulate button click in IE page
for example www.google.com
In my example the variable p is an IWebBrowser2 interface pointer. You need
to walk the IE DOM to locate the button of interest, and then call the click
method.

You need to do some reading around the IE DOM.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/doc_object.asp

Brian
Honsik
2007-04-13 19:02:18 UTC
Permalink
Post by Brian Muth
Post by Honsik
Thanks Brian, It is OK, but how can I simulate button click in IE page
for example www.google.com
In my example the variable p is an IWebBrowser2 interface pointer. You need
to walk the IE DOM to locate the button of interest, and then call the click
method.
You need to do some reading around the IE DOM.
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/doc_object.asp
Brian
Yes Brian, I am web programmer for long time, so I know it all. But
how can I access any button from C++. All examples on web page of
msdn, which you gave me, are only in HTML, JavaScript & CSS.

Can you write for me any example ?

Thanks a lot for your time
Brian Muth
2007-04-13 20:00:39 UTC
Permalink
Post by Honsik
Post by Brian Muth
Post by Honsik
Thanks Brian, It is OK, but how can I simulate button click in IE page
for example www.google.com
In my example the variable p is an IWebBrowser2 interface pointer. You need
to walk the IE DOM to locate the button of interest, and then call the click
method.
You need to do some reading around the IE DOM.
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/doc_object.asp
Brian
Yes Brian, I am web programmer for long time, so I know it all. But
how can I access any button from C++. All examples on web page of
msdn, which you gave me, are only in HTML, JavaScript & CSS.
Did you read up on IWebBrowser2?
Post by Honsik
Can you write for me any example ?
No, I won't write you any. There are lots of examples on the internet.
Exercise your Google skills. Here's a couple of links for starters:

http://www.codeproject.com/shell/iehelper.asp
http://www.codeproject.com/shell/AutomateShellWindow.asp

Brian
Honsik
2007-04-13 21:23:45 UTC
Permalink
Post by Brian Muth
Post by Honsik
Post by Brian Muth
Post by Honsik
Thanks Brian, It is OK, but how can I simulate button click in IE page
for example www.google.com
In my example the variable p is an IWebBrowser2 interface pointer. You need
to walk the IE DOM to locate the button of interest, and then call the click
method.
You need to do some reading around the IE DOM.
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/doc_object.asp
Brian
Yes Brian, I am web programmer for long time, so I know it all. But
how can I access any button from C++. All examples on web page of
msdn, which you gave me, are only in HTML, JavaScript & CSS.
Did you read up on IWebBrowser2?
Post by Honsik
Can you write for me any example ?
No, I won't write you any. There are lots of examples on the internet.
http://www.codeproject.com/shell/iehelper.asp
http://www.codeproject.com/shell/AutomateShellWindow.asp
Brian
Thank a lot, you are great. I have it yet.

Loading...