
Often, when developing, the programmer raises the question of displaying the results of work to the user in a form convenient for him. The benefit of the options for implementing the output of information is myriad. So, one of them is a web page, as a very flexible solution that allows you to format data in any form.
However, at times, a seemingly simple problem becomes complicated by some limitations. For example, due to lack of access rights, a situation may arise when the file system cannot be used. In other words, the results can not be saved to a file. And the use of the clipboard can lead to the destruction of important information stored in it.
How to show the user html page that does not have a local view under the cat.
The solution to the problem will be considered in C #. Using the following Active-X libraries from the Windows / System32 / folder:
- Microsoft HTML Viewer (mshtml.dll) - for object-oriented work with DHTML web page elements;
- Shell Doc Object and Control Library (SHDocVw.dll) - to perform basic operations with local and Internet resources.
With the first one we will generate the page itself, and the second will open it in the Internet Explorer browser. The main reason for using IE is the presence of it on almost any computer.
')
main idea
In any browser there are pages like about: ***, they are not stored locally, but are generated from the template when opened. For example, having written āabout: InPrivateā to the IE address bar, a service page will open, informing you that you have entered private browsing mode.

In order to understand how this mechanism works, let us turn to the Windows registry. To do this, use the standard Registry Editor program (Run -> regedit). Open the path HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Internet Explorer / AboutURLs. Here it is looking for a browser template for the page, the link to which we indicated after the word about.

As you can see, under the mask āabout: InPrivateā hides the address of the location of that very page: res: //iframe.dll/inprivate.htm. It follows that the desired page is in the resources of the ieframe.dll library. (Read more about Dll resources and how to create them, you can read on
MSDN )
Implementation
var ie = new InternetExplorer(); ie.Navigate(@"about:blank"); var document = ie.Document; document.open(); var element = document.createElement("body"); var nodeBody = document.ImportNode(element, true); document.appendChild(nodeBody); var stringBuilder = new StringBuilder(); stringBuilder.Append("<div id=\"Content\" style=\" " + "font-family:Segoe UI; " + "text-align:center; " + "width:500px; " + "border:1px solid black; " + "float:left; " + "padding-bottom:10px;" + "margin: 5px auto;\">" ); document.body.insertAdjacentHTML("beforeEnd", stringBuilder.ToString()); var content = document.getElementById("Content"); stringBuilder.Clear(); stringBuilder.Append("<h1> IE </h1>" + "<h3> </h3><br/>" + "<hr style=\"width:100px;\"/><br/>" + "<p> , ! </p>" ); content.insertAdjacentHTML("beforeEnd", stringBuilder.ToString()); document.body.insertAdjacentHTML("beforeEnd", "</div>"); document.close(); ie.Visible = true;
The code is basically simple, I think itās not necessary to explain line by line, Iāll tell you the essence:
- Create an instance of the interface for working with IE;
- We open the page already available on the computer (in our case it is a blank page);
- Extract "Document" from IE, this is an object representation of our page;
- Fill it with the necessary content;
- (Required) Close the document - IE displays the changes.

That's it, the software-generated page with our content is displayed in the browser without using the file system and the clipboard.
Thus, it is possible to use a complex page layout written to the dll library to display frequently changing data instead of creating new files multiple times.