..
This commit is contained in:
74
Program.cs
74
Program.cs
@@ -3,6 +3,10 @@ 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
|
||||
{
|
||||
@@ -16,7 +20,75 @@ namespace VNCServerList
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user