[英]c# - navigate url with using iexplore.exe -embedding?
I navigate an url using c# using; 我使用c#使用浏览网址;
SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
IE.Navigate2("http://example.org");
It uses iexplore.exe (Internet explorer) on backend to navigate the url. 它在后端使用iexplore.exe(Internet Explorer)浏览URL。 But I want the program to use "iexplore.exe -embedding" instead of "iexplore.exe", means that I want to add that command when the program using the iexplore.exe 但是我希望程序使用“ iexplore.exe -embedding”而不是“ iexplore.exe”,这意味着我想在使用iexplore.exe的程序中添加该命令。
What is the correct way to do that ? 正确的做法是什么?
You can run ieexplorer as new process by command line 您可以通过命令行将ieexplorer作为新进程运行
Process.Start("iexplore.exe -embedding " + yourUrl);
There is more details http://www.dotnetperls.com/process 有更多详细信息http://www.dotnetperls.com/process
As @Jacek points out you can run your own process with whatever CLI flags you want . 正如@Jacek指出的那样,您可以使用任何所需的CLI标志运行自己的进程。 Then you just need to use SHDocVw.ShellWindows to iterate over all of the existing IE instances to find the one you started. 然后,您只需要使用SHDocVw.ShellWindows对所有现有IE实例进行迭代,以找到您启动的实例。
You have a couple options in this regard, you can cross reference the result of Process.Start()'s Id property to give you a PID, which you can compare with known PID's previously found to find the "new" one. 在这方面,您有两个选择,您可以交叉引用Process.Start()的Id属性的结果以提供给您一个PID,您可以将其与先前找到的已知PID进行比较以找到“新”的PID。 You can also navigate to a unique URL and filter for that URL in the ShellWindows() iteration . 您还可以导航到唯一URL并在ShellWindows()迭代中对该URL进行过滤。
If you need to maintain a reference point to that browser across process invocations or despite subsequent user navigation in the browser instance you can also use PutProperty to assign it a unique key-value pair that you can reference again and again across multiple host process invocations (the IE window must remain running for this value to persist.) 如果您需要在流程调用之间维护该浏览器的引用点,或者尽管在浏览器实例中进行了后续用户导航,则也可以使用PutProperty为其分配唯一的键值对,您可以在多个主机流程调用之间反复引用( IE窗口必须保持运行状态,此值才能保留。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.