mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-08-18 15:33:33 +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:
45
LanMountainDesktop.Platform.Windows/WindowsDwmInterop.cs
Normal file
45
LanMountainDesktop.Platform.Windows/WindowsDwmInterop.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LanMountainDesktop.Platform.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// DWM(桌面窗口管理器)互操作封装。
|
||||
/// </summary>
|
||||
public static class WindowsDwmInterop
|
||||
{
|
||||
public const int WindowAttributeBorderColor = 34;
|
||||
public const uint ColorNone = 0xFFFFFFFE;
|
||||
|
||||
/// <summary>
|
||||
/// 移除窗口原生边框颜色(Windows 11 22000+)。
|
||||
/// 失败静默忽略(DWM 属性为尽力而为语义)。
|
||||
/// </summary>
|
||||
public static void TryDisableWindowBorder(IntPtr windowHandle)
|
||||
{
|
||||
if (windowHandle == IntPtr.Zero || !OperatingSystem.IsWindowsVersionAtLeast(10, 0, 22000))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var borderColor = ColorNone;
|
||||
_ = DwmSetWindowAttribute(
|
||||
windowHandle,
|
||||
WindowAttributeBorderColor,
|
||||
ref borderColor,
|
||||
sizeof(uint));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// DWM attributes are best-effort and unavailable on older/unsupported Windows builds.
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("dwmapi.dll")]
|
||||
private static extern int DwmSetWindowAttribute(
|
||||
IntPtr windowHandle,
|
||||
int attribute,
|
||||
ref uint attributeValue,
|
||||
int attributeSize);
|
||||
}
|
||||
Reference in New Issue
Block a user