//添加命名空間

using System.Diagnostics;

namespace //以最大化啟動記事本

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

       

//啟動記事本

        private void button1_Click(object sender, EventArgs e)

        {

            try

            {

                ProcessStartInfo MyStarInfo = new ProcessStartInfo();

                MyStarInfo.FileName="Notepad.exe";

 

                //視窗起始狀態最大化

                MyStarInfo.WindowStyle = ProcessWindowStyle.Maximized;

                Process MyProcees = new Process();

                MyProcees.StartInfo = MyStarInfo;

                MyProcees.Start();

            }

            catch (Exception ex) //避免產生錯誤而造成當機

            {              

                MessageBox.Show(ex.Message, "資訊提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

arrow
arrow
    全站熱搜

    Barry 發表在 痞客邦 留言(2) 人氣()