Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IExplorer controled from Visual C++ 5

Posted on 1997-08-12
8
Medium Priority
?
691 Views
Last Modified: 2013-12-03
I have been trying to run Internet Explorer from my program.
This doesn't seem to work.  I have looked at the help that
comes with VC5 and I can see that there is a CLSID_IExplorer
defined there.  I tried that with CoGetClassObject but VC5 didn't
know anything about this classID.
The help also says something about IWebBrowserApp but VC5
Doesn't know that type either.
Well I could go on for every about all my stupid tries to get this to work.  I haven't done any COM programming before so I am probably doing something wrong here.
So what a want to ask is for VC code that can start or take over IE and hand me an object that I can use with all the functions defined in the help.  I don't need a complete program just code to do this.
0
Comment
Question by:gvg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 1

Author Comment

by:gvg
ID: 1403723
Edited text of question
0
 
LVL 3

Accepted Solution

by:
vinniew earned 400 total points
ID: 1403724
Here's the answer:

You need to find the exact IID of Internet explorer in the registry, first.  It's going to depend on version number, so you'll have to check those.

It will be in HKEY_CLASSES_ROOT.


Then, you can start using COM.  

Here's what is going on:
COM API function uses CLSID to look up the filename in the registry(iexplore.exe) and where it's at.  Then, it searches for the vtable in the binary that stores all the function pointers.  The pointers are in a specific order.  If you know what parameters they take and have them defined correctly, you can now use them.

Basically, what you are doing is:

pUnknown->vTable->Foo()

The COM API will get you the pUnknown, but you have to have the interface struct.

Do you really have something like this:

MyInterfaceExplorer : public IUnknown
{
   int home(void);
...
...
...
};

?

I don't know where you got that, but it's the list of how the function pointers are ordered in the iexplore.exe vtable.

You can use CoCreateInstanceEx to start up your COM object and get the pUnknown, but I need that Interface definition if you want sample code.

Oh, one other thing.  VB uses a standard function pointer in the vtable, GetIDSOfNames(), to use the functions via another function.  You might have better luck with that, although it's slower.


Send the Interface struct if you want more.

V


0
 
LVL 1

Author Comment

by:gvg
ID: 1403725
Well I don't have the Interface struct but in the ActiveX SDK from Microsoft the "class" or "Interface" is defined.
2 interfaces are defined there, the IWebBrowserApp and IWebBrowser where IWebBrowserApp is a superset of IWebBrowser.
I found the GUID for IExplorer in the registry and then used a macro called
DEFINE_GUID( ... )
This didn't link because DEFINE_GUID is somekind of extern macro and a also don't have REFIDs for thoes 2 interfaces.
What I was hoping for is that here is somewhere a include file witch defines IWebBrowserApp and IWebBrowser and also has the REFID's for thoes interfaces.  If there is none why do the put this into the ActiveX SDK?
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 3

Expert Comment

by:vinniew
ID: 1403726
Here is a small part of exdisp.h where I found the IWebBrowser interface:

/* Definition of interface: IWebBrowser */
#undef INTERFACE
#define INTERFACE IWebBrowser

DECLARE_INTERFACE_(IWebBrowser, IDispatch)
{
#ifndef NO_BASEINTERFACE_FUNCS

    /* IUnknown methods */
    STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
    STDMETHOD_(ULONG, Release)(THIS) PURE;

    /* IDispatch methods */
    STDMETHOD(GetTypeInfoCount)(THIS_ UINT FAR* pctinfo) PURE;

    STDMETHOD(GetTypeInfo)(
      THIS_
      UINT itinfo,
      LCID lcid,
      ITypeInfo FAR* FAR* pptinfo) PURE;

    STDMETHOD(GetIDsOfNames)(
      THIS_
      REFIID riid,
      OLECHAR FAR* FAR* rgszNames,
      UINT cNames,
      LCID lcid,
      DISPID FAR* rgdispid) PURE;

    STDMETHOD(Invoke)(
      THIS_
      DISPID dispidMember,
      REFIID riid,
      LCID lcid,
      WORD wFlags,
      DISPPARAMS FAR* pdispparams,
      VARIANT FAR* pvarResult,
      EXCEPINFO FAR* pexcepinfo,
      UINT FAR* puArgErr) PURE;
#endif

    /* IWebBrowser methods */
    STDMETHOD(GoBack)(THIS) PURE;
    STDMETHOD(GoForward)(THIS) PURE;
    STDMETHOD(GoHome)(THIS) PURE;
    STDMETHOD(GoSearch)(THIS) PURE;
    STDMETHOD(Navigate)(THIS_ BSTR URL, VARIANT FAR* Flags, VARIANT FAR* TargetFrameName, VARIANT FAR* PostData, VARIANT FAR* Headers) PURE;
    STDMETHOD(Refresh)(THIS) PURE;
    STDMETHOD(Refresh2)(THIS_ VARIANT FAR* Level) PURE;
    STDMETHOD(Stop)(THIS) PURE;
    STDMETHOD(get_Application)(THIS_ IDispatch * FAR* ppDisp) PURE;
    STDMETHOD(get_Parent)(THIS_ IDispatch * FAR* ppDisp) PURE;
    STDMETHOD(get_Container)(THIS_ IDispatch * FAR* ppDisp) PURE;
    STDMETHOD(get_Document)(THIS_ IDispatch * FAR* ppDisp) PURE;
    STDMETHOD(get_TopLevelContainer)(THIS_ VARIANT_BOOL FAR* pBool) PURE;
    STDMETHOD(get_Type)(THIS_ BSTR FAR* pbstrType) PURE;
    STDMETHOD(get_Left)(THIS_ long FAR* pl) PURE;
    STDMETHOD(put_Left)(THIS_ long Left) PURE;
    STDMETHOD(get_Top)(THIS_ long FAR* pl) PURE;
    STDMETHOD(put_Top)(THIS_ long Top) PURE;
    STDMETHOD(get_Width)(THIS_ long FAR* pl) PURE;
    STDMETHOD(put_Width)(THIS_ long Width) PURE;
    STDMETHOD(get_Height)(THIS_ long FAR* pl) PURE;
    STDMETHOD(put_Height)(THIS_ long Height) PURE;
    STDMETHOD(get_LocationName)(THIS_ BSTR FAR* pbstrLocationName) PURE;
    STDMETHOD(get_LocationURL)(THIS_ BSTR FAR* pbstrLocationURL) PURE;
    STDMETHOD(get_Busy)(THIS_ VARIANT_BOOL FAR* pBool) PURE;
};

I'll write more tomorrow, but this will be part of the #includes...

TTFN

V

0
 
LVL 1

Author Comment

by:gvg
ID: 1403727
Looking forward to see more
0
 
LVL 3

Expert Comment

by:vinniew
ID: 1403728
Ok,

So you have the interface included somewhere...

You can then use something like:
DEFINE_GUID(yatta,yatta,yatta)

 hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);    // make sure the project has COM/Automation settings, too.
 IWebBrowser *pPoint = 0;
 CoCreateInstance(CLSID_Browser, 0,
                  CLSCTX_INPROC_SERVER,
                  IID_IWebBrowser, (void**)&pPoint);


This will get you a pointer to pUnknown.  The WebBrowser class structure is nested in this.  So, something like:

DWORD dwHeight = pPoint->get_Height() should then function


I'll test this out today sometime...

V

0
 
LVL 1

Author Comment

by:gvg
ID: 1403729
I tried this last night and my CoCreateInstance return S_OK whitch is good.
But my problem was that when I
CLSID_InternetExplorer witch was OK and IID_IWebBrowser witch was not OK because it didn't link.  I read somewhere that this DEFINE_GUID macro had 2 diffrent implimentations and one of the was extern.
I looked at exdisp.h where both of this GUIDs are defined but I couldn't see any diffrance in them.
So CoCreateInstance worked only if I used
CLSID_InternetExplorer and IID_IUnknown.
I didn't see any IE come up and when I tried some functions it didn't work.


0
 
LVL 3

Expert Comment

by:vinniew
ID: 1403730
If you want IE to come up, use IWebBrowserApp.  It inherits IWebBrowser.

V

0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question