95 lines
3.5 KiB
C#
95 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Microsoft.Web.WebView2.Core;
|
|
using System.IO;
|
|
using System.Net;
|
|
using System.Diagnostics;
|
|
|
|
namespace VNCServerList
|
|
{
|
|
static class Program
|
|
{
|
|
/// <summary>
|
|
/// 해당 응용 프로그램의 주 진입점입니다.
|
|
/// </summary>
|
|
[STAThread]
|
|
static void Main()
|
|
{
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
// WebView2 런타임 확인 및 자동 다운로드
|
|
if (!WebView2Installer.IsWebView2Installed())
|
|
{
|
|
var result = MessageBox.Show(
|
|
"WebView2 런타임이 설치되지 않았습니다.\n\n" +
|
|
"자동으로 다운로드하여 설치하시겠습니까?\n\n" +
|
|
"예: 자동 다운로드 및 설치\n" +
|
|
"아니오: 수동으로 다운로드 페이지 열기",
|
|
"WebView2 런타임 설치",
|
|
MessageBoxButtons.YesNo,
|
|
MessageBoxIcon.Question);
|
|
|
|
if (result == DialogResult.Yes)
|
|
{
|
|
// 비동기로 설치 실행
|
|
var installTask = WebView2Installer.InstallWebView2Async();
|
|
|
|
// 설치 완료 대기
|
|
bool success = installTask.Result;
|
|
|
|
if (success)
|
|
{
|
|
MessageBox.Show(
|
|
"WebView2 런타임 설치가 완료되었습니다.\n" +
|
|
"프로그램을 다시 실행해주세요.",
|
|
"설치 완료",
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Information);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show(
|
|
"WebView2 런타임 설치에 실패했습니다.\n" +
|
|
"수동으로 설치해주세요.",
|
|
"설치 실패",
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Warning);
|
|
|
|
// 수동 다운로드 페이지 열기
|
|
Process.Start("https://developer.microsoft.com/en-us/microsoft-edge/webview2/");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// WebView2 런타임 다운로드 페이지 열기
|
|
Process.Start("https://developer.microsoft.com/en-us/microsoft-edge/webview2/");
|
|
}
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
var userDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\VNCServerList\\WebView2Data";
|
|
var env = CoreWebView2Environment.CreateAsync(null, userDataFolder).Result;
|
|
|
|
Application.Run(new Form1());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(
|
|
"WebView2 초기화 중 오류가 발생했습니다.\n" +
|
|
"오류: " + ex.Message,
|
|
"오류",
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|