在C# 中写了个Winform程序,需要打开IE浏览器,现在想控制IE的窗口大小并屏蔽工具栏、地址栏,也就是只要标题栏的那种。
我的代码是用:
 ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
   startInfo.Arguments = "www.microsoft.com";
   Process process1=new Process ();
   process1.StartInfo =startInfo;
   process1.Start();
他是要设参数吗???哪些参数??
有没有别的方法??

解决方案 »

  1.   

    用WINFORM做一个IE界面,里面放一个IE控件
      

  2.   

    找找IE Automation的资料,大致步骤如下:
    1. 获取当前IE Shell窗口
    2. 修改窗口属性参考代码: http://www.codeproject.com/KB/cs/automatinginternetexplore.aspx
      

  3.   

    下面是段vbs代码
    Set ie= createobject("InternetExplorer.Application")ie.left=-5
    ie.top=-25
    ie.height=900 
    ie.width=1035
    ie.menubar=0
    ie.addressbar=0
    ie.toolbar=0 
    ie.statusbar=0
    ie.resizable=0
    ie.visible=1
    ie.navigate("http://www.sina.com.cn")呵呵,程序大多相通,谁说玩asp的就一定比不过net
      

  4.   

    你可以这样,用程序生成一个.html文件,里面用window.open方法开打你想要的网页。用window.open控制窗体的大小及其他。生成位置可以和你的exe同一位置。如下代码:
     static void Main(string[] args)
            {
                GenerateHTML();
                ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
                startInfo.Arguments = Environment.CurrentDirectory + "\\index.html";
                Process process1 = new Process();
                process1.StartInfo = startInfo;
                process1.Start(); 
            }        static void GenerateHTML()
            {
                string fileName = "index.html";
                string url = "http://www.microsoft.com";
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<html>");
                sb.AppendLine("<head>");
                sb.AppendLine("<script lanuage='javascript'>");
                sb.AppendLine("function init() {");
                sb.AppendFormat("window.open('{0}',null,'height=200,width=400,status=yes,toolbar=no,menubar=no,location=no');\n", url);
                sb.AppendLine("window.close();");
                sb.AppendLine("}");
                sb.AppendLine("</script>");
                sb.AppendLine("</head>");
                sb.AppendLine("<body onload='init()'>");
                sb.AppendLine("</body>");
                sb.AppendLine("</html>");
                using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                {
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        sw.Write(sb.ToString());
                        sw.Flush();
                    }
                }
            }
      

  5.   

    5楼的fangxinggood:
       你的方法虽然可以实现上述设想,但是存在一定的问题:
    1、在window.close()时总要询问是否关闭窗口
    2、在XP中运行JS,会出现“是否运行脚本”的提示
    以上两条影响到了用户的操作有没有更好的方法?就是能够直接打开,并指定URL,IE窗口还能定制?
      

  6.   

       public partial class Form1 : Form
        {
            public Type tIE;        public object oIE;        public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                object[] oParameter = new object[1];            tIE = Type.GetTypeFromProgID("InternetExplorer.Application");            oIE = Activator.CreateInstance(tIE);            oParameter[0] = (bool)true;            tIE.InvokeMember("Visible", BindingFlags.SetProperty, null, oIE, oParameter);            oParameter[0] = (string)"http://www.google.com";            tIE.InvokeMember("Navigate2", BindingFlags.InvokeMethod,                               null, oIE, oParameter);
                     }
        }
    }呵呵,跟你说过了程序大体相通,既然asp可以使用com,为啥net不能使用com呢?
      

  7.   

    另外:给你一个老外封装好的例子http://www.west-wind.com/WebLog/posts/2050.aspx
      

  8.   


    我再修改一下,结合楼上的VBS:
    static void Main(string[] args)
            {
                GenerateVBS();
                ProcessStartInfo startInfo = new ProcessStartInfo(Environment.CurrentDirectory + "\\openIE.vbs");
                //startInfo.Arguments = Environment.CurrentDirectory + "\\openIE.vbs";
                Process process1 = new Process();
                process1.StartInfo = startInfo;
                process1.Start(); 
            }        static void GenerateVBS()
            {
                string fileName = "openIE.vbs";
                string url = "http://www.microsoft.com";
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Set ie= createobject(\"InternetExplorer.Application\")");
                sb.AppendLine("ie.left=0");
                sb.AppendLine("ie.top=0");
                sb.AppendLine("ie.width=400");
                sb.AppendLine("ie.height=300");
                sb.AppendLine("ie.menubar=0");
                sb.AppendLine("ie.addressbar=0");
                sb.AppendLine("ie.toolbar=0");
                sb.AppendLine("ie.statusbar=0");
                sb.AppendLine("ie.resizable=0");
                sb.AppendLine("ie.visible=1");
                sb.AppendFormat("ie.navigate(\"{0}\")", url);
                using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                {
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        sw.Write(sb.ToString());
                        sw.Flush();
                    }
                }
            }
      

  9.   

    放一个webbrowser控件到Form里,控制Form的大小不就可以了么?
    怎么看你们都写了那么多啊?
      

  10.   

    用webbrowser控件打开的IE里面的链接全不能用了,,查查是因为webbrowser中的session不能跟IE交互,,,等于浪费时间,,要是你的IE页面没有其他链接了,可以考虑使用,,很方便也很简单