简体   繁体   English

C#-使用iexplore.exe -embeddding导航URL?

[英]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.

相关问题 c#:是否可以将参数挂接到现有进程。 启动iexplore.exe,然后使其导航到网站的示例 - c# : is it possible to hook arguments to an existing process. Example launching iexplore.exe and then making it to navigate to a website 的Process.Start(“IEXPLORE.EXE”); &lt; - 这可靠吗? - Process.Start(“IExplore.exe”); <— Is this reliable? IEXPLORE.exe的奇怪的ProcessorAffinity问题 - Strange ProcessorAffinity issue with IEXPLORE.exe Process.Kill似乎不适用于iexplore.exe - Process.Kill does not seem to work with iexplore.exe Process.Start("IExplore.exe"); --&gt; System.IO.FileNotFoundException - Process.Start("IExplore.exe"); --> System.IO.FileNotFoundException Process.Start(“ IExplore.exe”,“ http://google.com”)未在VM上启动。 在服务器和本地上工作 - Process.Start(“IExplore.exe”, “http://google.com”) Not Launching On VM. Works on Server and Local Process.Start(“IEXPLORE.EXE”)在启动后立即触发退出事件..为什么? - Process.Start(“IEXPLORE.EXE”) immediately fires the Exited event after launch.. why? 在C#控制台中嵌入exe文件? - Embedding an exe file in C# console? 使用C#登录instagram后如何导航到新网址 - How to navigate to new url after login to instagram using c# 在Visual C#2010中将DLL嵌入到.exe中 - Embedding DLL's into .exe in in Visual C# 2010
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM