mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-08-19 00:03:24 +08:00
refactor: 新建 Platform 平台差异层,主工程 P/Invoke 全部迁出
- 新增 Platform.Abstractions(接口+NoOp+PlatformLog 日志桥)、 Platform.Windows、Platform.MacOS、Platform.Android 四个项目 - 迁移电源管理、原生对话框、桌面层嵌入、窗口置底/区域穿透、 DWM 互操作、图标服务、包标识查询等全部 Windows P/Invoke 实现 - 主工程保留静态工厂门面,调用点不变;DllImport 扫描为零 - 更新 WindowPassthroughServiceTests 指向新位置(20/20 通过)
This commit is contained in:
30
LanMountainDesktop.Platform.Windows/WindowsNativeDialogs.cs
Normal file
30
LanMountainDesktop.Platform.Windows/WindowsNativeDialogs.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LanMountainDesktop.Platform.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// Windows 原生消息框(MessageBoxW)封装。
|
||||
/// 供宿主在 UI 框架尚不可用(启动早期)时显示诊断信息。
|
||||
/// </summary>
|
||||
public static class WindowsNativeDialogs
|
||||
{
|
||||
public const uint Ok = 0x00000000;
|
||||
public const uint IconInformation = 0x00000040;
|
||||
public const uint IconWarning = 0x00000030;
|
||||
|
||||
/// <summary>
|
||||
/// 显示原生消息框。仅在 Windows 上有效,其他平台为空操作。
|
||||
/// </summary>
|
||||
public static void Show(string caption, string message, uint type)
|
||||
{
|
||||
if (!OperatingSystem.IsWindows())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ = MessageBoxW(IntPtr.Zero, message, caption, type);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "MessageBoxW", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
private static extern int MessageBoxW(IntPtr hWnd, string text, string caption, uint type);
|
||||
}
|
||||
Reference in New Issue
Block a user