How to access HTML document using Win32 VC++ from a manually launched HTML file in Microsoft Edge.

Syed Kamal Ahmed Hiron 5 Reputation points
2023-07-10T09:22:10.77+00:00

How to access HTML document using Win32 VC++ from a manually launched HTML file in Microsoft Edge. My requirement:

  1. We are having an application developed in VC++
  2. A user will first manually launch a HTML file using Edge.
  3. The user will then launch the VC++ application which would first identify the Microsoft Edge browser which is already launched manually
  4. The application will then access the HTML document object from the Edge browser.

Previously it was done like the below. But it was only for Internet Explorer. As Internet explorer has been discontinued already we have to replace this functionality asap:

/*************************************************************** MSHTML::IHTMLDocument2Ptr spDocument;

SHDocVw::IShellWindowsPtr m_spSHWinds;

//This is for identifying the Windows currently launched

m_spSHWinds.CreateInstance( SHDocVw::CLSID_ShellWindows );

// Accessing Manually launched HTML file in IWebBrowser2Ptr (IWebBrowser2Ptr interface is used only for IE)

SHDocVw::IWebBrowser2Ptr spBrowser = m_spSHWinds->Item( Index );

//Getting HTML Document object

spDocument = spBrowser->GetDocument(); /***************************************************************
So, I would like to do the same thing but for Microsoft Edge. Any sort of information regarding this would be great!

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,856 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Castorix31 86,986 Reputation points
    2023-07-10T10:06:29.6066667+00:00

    With ExecuteScriptAsync

    (for example document.documentElement.outerHTML for HTML source)


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.