Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. shdocvw.dll - WebBrowser control

shdocvw.dll - WebBrowser control

Scheduled Pinned Locked Moved C / C++ / MFC
comhelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Force Code
    wrote on last edited by
    #1

    Trying to create and access a WebBrowser control behind the scenes in a win32 console app:

    ::CoInitialize(NULL);

    SHDocVw::IWebBrowser2Ptr brwsr = NULL;
    HRESULT hResult;

    hResult = brwsr.CreateInstance(__uuidof(SHDocVw::WebBrowser));

    //hResult = CoCreateInstance(_uuidof(SHDocVw::WebBrowser), NULL,
    // CLSCTX_SERVER, __uuidof(IWebBrowser2), (LPVOID*)&brwsr);

    I can then call brwsr->get_Name, brwsr->get_FullName etc. with no problem. brwsr->Navigate(...) is causing a runtime crash (with CoCreateInstance or CreateInstance.) Here's the current method I'm using:

    BSTR oURL;
    oURL = SysAllocString(L"http://www.google.com");
    VARIANT var;
    var.vt = VT_EMPTY;
    brwsr->Navigate((BSTR)oURL, &var, &var,
    &var,&var);
    SysFreeString(oURL);

    (which I copied and pasted from somewhere). Have no idea if anybody still uses COM, but does someone know what I'm doing wrong.

    CPalliniC L 2 Replies Last reply
    0
    • F Force Code

      Trying to create and access a WebBrowser control behind the scenes in a win32 console app:

      ::CoInitialize(NULL);

      SHDocVw::IWebBrowser2Ptr brwsr = NULL;
      HRESULT hResult;

      hResult = brwsr.CreateInstance(__uuidof(SHDocVw::WebBrowser));

      //hResult = CoCreateInstance(_uuidof(SHDocVw::WebBrowser), NULL,
      // CLSCTX_SERVER, __uuidof(IWebBrowser2), (LPVOID*)&brwsr);

      I can then call brwsr->get_Name, brwsr->get_FullName etc. with no problem. brwsr->Navigate(...) is causing a runtime crash (with CoCreateInstance or CreateInstance.) Here's the current method I'm using:

      BSTR oURL;
      oURL = SysAllocString(L"http://www.google.com");
      VARIANT var;
      var.vt = VT_EMPTY;
      brwsr->Navigate((BSTR)oURL, &var, &var,
      &var,&var);
      SysFreeString(oURL);

      (which I copied and pasted from somewhere). Have no idea if anybody still uses COM, but does someone know what I'm doing wrong.

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Force Code wrote:

      Have no idea if anybody still uses COM, but does someone know what I'm doing wrong.

      Nope. Nobody uses COM nowdays. But a long time ago (I was just a child), a wise COM guru told me: "Check always HRESULTs, my son!" :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      [my articles]

      In testa che avete, signor di Ceprano?

      F 1 Reply Last reply
      0
      • CPalliniC CPallini

        Force Code wrote:

        Have no idea if anybody still uses COM, but does someone know what I'm doing wrong.

        Nope. Nobody uses COM nowdays. But a long time ago (I was just a child), a wise COM guru told me: "Check always HRESULTs, my son!" :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        [my articles]

        F Offline
        F Offline
        Force Code
        wrote on last edited by
        #3

        The fact that its crashing on the brwsr->Navigate call sort of rules out checking the return value. What would you be using to access the web in a trivial win32 console app.

        CPalliniC 1 Reply Last reply
        0
        • F Force Code

          Trying to create and access a WebBrowser control behind the scenes in a win32 console app:

          ::CoInitialize(NULL);

          SHDocVw::IWebBrowser2Ptr brwsr = NULL;
          HRESULT hResult;

          hResult = brwsr.CreateInstance(__uuidof(SHDocVw::WebBrowser));

          //hResult = CoCreateInstance(_uuidof(SHDocVw::WebBrowser), NULL,
          // CLSCTX_SERVER, __uuidof(IWebBrowser2), (LPVOID*)&brwsr);

          I can then call brwsr->get_Name, brwsr->get_FullName etc. with no problem. brwsr->Navigate(...) is causing a runtime crash (with CoCreateInstance or CreateInstance.) Here's the current method I'm using:

          BSTR oURL;
          oURL = SysAllocString(L"http://www.google.com");
          VARIANT var;
          var.vt = VT_EMPTY;
          brwsr->Navigate((BSTR)oURL, &var, &var,
          &var,&var);
          SysFreeString(oURL);

          (which I copied and pasted from somewhere). Have no idea if anybody still uses COM, but does someone know what I'm doing wrong.

          L Offline
          L Offline
          Lim Bio Liong
          wrote on last edited by
          #4

          Hello Force Code, I'm not familiar with the IWebBrowser2 interface but after looking up the documentation for Navigate(), my gut feel is that the 2nd to the 5th parameters should be filled with VARIANT parameters that actually contain some information (rather than just being VT_EMPTY). Passing "NULL" might even be a better choice (I really don't know). My suggestion is to look up the documentation for Navigate() for proper guidance and then pass in appropriate values for the 2nd to 5th parameters. - Bio.

          1 Reply Last reply
          0
          • F Force Code

            The fact that its crashing on the brwsr->Navigate call sort of rules out checking the return value. What would you be using to access the web in a trivial win32 console app.

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            OK, but why do you call the method without filling parameters with meaningful values? I read a bit the documentation and it seems you cannot simply supply empty variants. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            [my articles]

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups