4

C# を使用して最大化された Internet Explorer を開く必要があります。私は次のことを試しました:

try
{
    var IE = new SHDocVw.InternetExplorer();
    object URL = "http://localhost/client.html";

    IE.ToolBar = 0;
    IE.StatusBar = true;
    IE.MenuBar = true;
    IE.AddressBar = true;
    IE.Width = System.Windows.Forms.SystemInformation.VirtualScreen.Width;
    IE.Height = System.Windows.Forms.SystemInformation.VirtualScreen.Height;

    IE.Visible = true;

    IE.Navigate2(ref URL);
    ieOpened = true;

    break;
}
catch (Exception)
{

}

さまざまなサイズで開くことができますが、最大化された IE を開く方法が見つかりませんでした。msdnを確認しましたが、最大化するためのプロパティはありません。

いくつかの提案をお願いします。

PS: C# コンソール アプリケーション、.Net4.5、および VS2012 を開発しています。

4

4 に答える 4

7
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Maximize_IE
{
    class Program
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        static void Main(string[] args)
        {
            var IE = new SHDocVw.InternetExplorer();
            object URL = "http://google.com/";

            IE.ToolBar = 0;
            IE.StatusBar = true;
            IE.MenuBar = true;
            IE.AddressBar = true;

            IE.Visible = true;
            ShowWindow((IntPtr)IE.HWND, 3);
            IE.Navigate2(ref URL);
            //ieOpened = true;
        }
    }
}
于 2014-08-13T10:32:56.737 に答える
5

process メソッドを使用します。

  1. 任意の実行可能ファイルを起動して、
  2. プロセスを最大化して開始するプロパティがあります

    ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
    startInfo.WindowStyle = ProcessWindowStyle.Maximized;
    startInfo.Arguments = "www.google.com";
    
    Process.Start(startInfo);
    
于 2014-08-13T10:18:30.240 に答える
3

「csharp 最大化 SHDocVw ウィンドウ」のクイック グーグルは、次の例を示します。

[DllImport ("user32.dll")]
private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
private const int SW_MAXIMISE = 3;

public void OpenWindow()
{
       SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();  //Instantiate the class.
        ShowWindow((IntPtr)ie.HWND, SW_MAXIMISE);   //Maximise the window.
        ie.Visible = true;   //Set the window to visible.
}
于 2014-08-13T10:19:32.460 に答える
1

これを試して:

  var proc = new Process
            {
              StartInfo = {
                 UseShellExecute = true,
                 FileName = "http://localhost/client.html",
                 WindowStyle = ProcessWindowStyle.Maximized
              }
            };
  proc.Start();
于 2014-08-13T10:19:58.593 に答える