첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

■ 업데이트 프로그램을 강제 실행하는 코드를 추가하는 방법을 보여준다.

 

▶ Program.cs

using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;

namespace TestProject
{
    /// <summary>
    /// 프로그램
    /// </summary>
    static class Program
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region 프로그램 시작하기 - Main()

        /// <summary>
        /// 프로그램 시작하기
        /// </summary>
        [STAThread]
        private static void Main()
        {
            try
            {
                string path = Path.Combine(Application.StartupPath, "updater.exe");

                if(File.Exists(path))
                {
                    Process process = Process.Start(path, "/silentall");

                    process.WaitForExit();

                    if(process.ExitCode == 0)
                    {
                        return;
                    }
                }
            }
            catch
            {
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }

        #endregion
    }
}
728x90
그리드형(광고전용)
Posted by icodebroker
,