Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

IExplorer controled from Visual C++ 5

Posted on 1997-08-12
8
Medium Priority
?
702 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
  • 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

971 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