Подтвердить что ты не робот

Открыть веб-страницу в IE с помощью С#

Как открыть веб-страницу в IE, нажав кнопку в приложении С#. Мое намерение - создать веб-логин для приложения С#, который нужно открыть в IE, в указанной ширине и высоте, и ему нужно вызвать функцию в прикладной программе.

4b9b3361

Ответ 1

из http://msdn.microsoft.com/en-us/library/system.diagnostics.process(VS.71).aspx

using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    /// <summary>
    /// Shell for the sample.
    /// </summary>
    public class MyProcess
    {

        /// <summary>
        /// Opens the Internet Explorer application.
        /// </summary>
        public void OpenApplication(string myFavoritesPath)
        {
            // Start Internet Explorer. Defaults to the home page.
            Process.Start("IExplore.exe");

            // Display the contents of the favorites folder in the browser.
            Process.Start(myFavoritesPath);

        }

        /// <summary>
        /// Opens urls and .html documents using Internet Explorer.
        /// </summary>
        public void OpenWithArguments()
        {
            // url are not considered documents. They can only be opened
            // by passing them as arguments.
            Process.Start("IExplore.exe", "www.northwindtraders.com");

            // Start a Web page using a browser associated with .html and .asp files.
            Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
            Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
        }

        /// <summary>
        /// Uses the ProcessStartInfo class to start new processes, both in a minimized 
        /// mode.
        /// </summary>
        public void OpenWithStartInfo()
        {

            ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
            startInfo.WindowStyle = ProcessWindowStyle.Minimized;

            Process.Start(startInfo);

            startInfo.Arguments = "www.northwindtraders.com";

            Process.Start(startInfo);

        }

        public static void Main()
        {
                    // Get the path that stores favorite links.
                    string myFavoritesPath = 
                    Environment.GetFolderPath(Environment.SpecialFolder.Favorites);

                    MyProcess myProcess = new MyProcess();

            myProcess.OpenApplication(myFavoritesPath);
            myProcess.OpenWithArguments();
            myProcess.OpenWithStartInfo();

               }    
    }
}

Ответ 2

System.Diagnostics.Process.Start("iexplore", "http://example.com");

Ответ 3

Существует способ открыть страницу в браузере по умолчанию System.Diagnostics.Process.Start(url);

Если вы хотите специально открыть его в IE, вам, вероятно, потребуется создать новый процесс IE с URL-адресом в качестве аргумента.

UPD:. Если вы хотите запустить функцию, вставьте параметры GET в строку url (т.е. http://stackoverflow.com/page?runFunction=1), а в коде вашего кода проверьте параметр runFunction и на основе его значения решите, ваше приложение должно запустить функцию.

Я не думаю, что можно указать новые значения ширины и высоты окна IE, вам может понадобиться использовать javascript для этого.