用.NetStandard打开自定义的外部网络浏览器。

问题描述 投票:0回答:1

我们需要能够从我们的应用程序(.NetStandard 2.0)中打开一个Web浏览器。浏览器应该作为一个外部应用程序打开,需求并不要求将浏览器嵌入到我们的应用程序中,因此使用WebBroswer控件不是一个选项。我们需要能够指定以下选项。

  • 浏览器的高度
  • 浏览器的宽度
  • 最高位置
  • 左侧位置
  • 启用或禁用地址栏
  • 启用或禁用Menubar
  • 启用或禁用状态栏
  • 启用或禁用工具栏

我们最初认为使用Process类就可以了,但似乎这些选项不能用Process类来指定。如果有任何关于如何实现这一功能的文章或建议,我们将非常感激。

c# internet-explorer .net-core .net-standard-2.0
1个回答
0
投票

你可以考虑创建一个Windows Form应用程序或 WPF应用,然后使用 WebBrowser控件 来显示网页。

关于WebBrowser控件的详细使用方法,请查看以下链接。

WebBrowser控件概述

怎么做。添加Web浏览器功能到Windows窗体应用程序中

如何在WebBrowser控件中显示地址栏?

WPF中的WebBrowser控件

尽量使用 InternetExplorer对象 来控制Windows Internet Explorer的实例。

首先,右击应用程序 参考资料 并选择 添加参考资料 选项,然后在 COM 选项卡,检查了 微软互联网控制 并点击 好的 来添加引用。

enter image description here

然后,参考下面的代码来使用InternetExplorer对象。

        SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();
        ie.Navigate("http://www.bing.com");
        ie.ToolBar = 0; //hide or display the toolbar.
        ie.AddressBar = false; //hide or display the AddressBar.
        ie.Left = 200;
        ie.Height = 800;
        ie.Width = 500;
        ie.StatusBar = false; // hide or display the statusBar.
        ie.Visible = true; //display IE browser.

更多关于属性的详细信息,请查看《InternetExplorer》中的 IWebBrowser2接口.

© www.soinside.com 2019 - 2024. All rights reserved.