internet explorer - .NET: How to make WebBrowser control launch in IE, display HTML, out of process? -
I want to create a WebBrowser control, give HTML to display it, then it's out of the process in my own internet Get out
Can this be done?
- Yes it is to be out of the process
- I already have a technique that involves writing a temporary file I want to delete this hack solution < / Li>
I have three other questions that are running stack overflow, all of which work on the following small segments of code work:
Public Stable Zero Spoenerator (String SJHML) {IWebBrowser2 ie = (IWebBrowser2) New Internet Explorer Rare (); Object MV = System Reflection.Missing.Value; // Special "Nothing" value object url = (string) @ "about: blank"; Ie.Navigate2 (Riff URL, Ref MV, Ref MV, Ref MV, Ref MV); Mshtml.HTMLDocumentClass doc = (mshtml.HTMLDocumentClass) ie.Document; Doc.Write (szHtml); Doc.Close (); Ie.Visible = true; } Note: The above code works fine in the local app. I thought that I will do it in order to pursue, and if there is no other idea, the only way in which I am able to understand it is not included.
The hack solution, which uses a temporary file, is:
Public Static Zero SpoEnivators (String SJHML) {IWebBrowser2 ie = (IWebBrowser2) New InternetExplorer (); Object MV = System Reflection.Missing.Value; // Special "Nothing" value object url = (string) @ "about: blank"; Ie.Navigate2 (Riff URL, Ref MV, Ref MV, Ref MV, Ref MV); // Todo: Look at the NAT equivalent of the following so that it does not have to write a temporary file / IDISpatch web document = i.e. the document; //webDocument.Write(szHtml); //webDocument.Close (); String tempFilename = path. GetTempFileName (); try {//. Rename the Htm, or else it will not show the actual HTML string as HTML filename = path. Change Extension (tempFilename, "htm"); File. Forward (tempFilename, html file); // file of .NET file. Rename tempFilename = htmlFile; // StreamWriter author = write string to file new streamer (TempFilename); Author.Write (szHtml); Writer.Close (); Url = (string) tempFilename; Ie.Navigate2 (Riff URL, Ref MV, Ref MV, Ref MV, Ref MV); // If we want to delete the file, then we have to wait for IE to use it. We must remove it before using it (i.e. RDDSTATE! = Tag READYSTATE.READYSTATE_COMPLETE) {System.Threading. Thread sleep (10); }} {File.Delete (tempFilename) at the end; } // create IE visibol Ivizible = true; }
The way I did before, it is to save the HTML file to disk , And pass the filename in the shell, such as:
System.Diagnostics.Process p = new System.Diagnostics.Process (); P.StartInfo.FileName = "C: \ path \ to myHTMLFile.html"; P.StartInfo.UseShellExecute = True; P.StartInfo.RedirectStandardOutput = false; P.StartInfo.Arguments = ""; P.Start ();
The obvious thing about this is that it will open with the user's default web browser. If you need IE, then you have to dig into the registry and get your path, and it must be executed specifically.
You can also do this when the process is completely settled. There is an event that you can subscribe to, which is called, which can inform you how the process can be settled.
Comments
Post a Comment