Bal*_*alu 4 c# internet-explorer shdocvw
我必须使用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)
{
}
Run Code Online (Sandbox Code Playgroud)
我可以打开不同的大小,但我找不到如何打开最大化的IE.我检查了msdn,没有属性可以最大化.
请给我一些建议.
PS:我正在开发C#控制台应用程序,.Net4.5和VS2012
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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 6
我会使用流程方法.
它有一个属性,可以使您的流程最大化
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
startInfo.Arguments = "www.google.com";
Process.Start(startInfo);
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
4695 次 |
| 最近记录: |