Skip to content

Commit f5c27b4

Browse files
committed
使用 Win32 API 替换 vbscript 弹窗,优化扩展文件名注册成功提示
1 parent 00d8544 commit f5c27b4

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

ExtensionRegister/Program.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
using System;
2-
using System.Diagnostics;
32
using System.IO;
3+
using System.Runtime.InteropServices;
44
using Microsoft.Win32;
55

66
namespace ExtensionRegister
77
{
88
class Program
99
{
10+
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
11+
public static extern int MessageBoxW(IntPtr hWnd, string text, string caption, uint type);
12+
1013
static void Main(string[] args)
1114
{
1215
string path = AppDomain.CurrentDomain.BaseDirectory;
@@ -33,16 +36,12 @@ static void Main(string[] args)
3336
key.SetValue("", "LuaSTG.File");
3437
key = Registry.ClassesRoot.CreateSubKey(".lstgproj", true);
3538
key.SetValue("", "LuaSTG.Project");
36-
Process p = new Process()
37-
{
38-
StartInfo = new ProcessStartInfo()
39-
{
40-
FileName = "mshta.exe",
41-
Arguments = $"vbscript:msgbox(\"已成功注册扩展文件名(.lstges, .lstgproj)目标至{Environment.NewLine}{sharp_path}\",64,\"LuaSTG Sharp Editor\")(window.close)",
42-
CreateNoWindow = true
43-
}
44-
};
45-
p.Start();
39+
40+
// 使用 Win32 API 弹窗
41+
MessageBoxW(IntPtr.Zero,
42+
$"已成功注册扩展文件名(.lstges, .lstgproj)目标至\n{sharp_path}",
43+
"LuaSTG Sharp Editor",
44+
0x40); // 0x40 = MB_ICONINFORMATION
4645
}
4746
}
4847
}

0 commit comments

Comments
 (0)