A: 新增ExceptionExpand异常处理类及相关枚举 (Infrastructure/ExceptionExpand.cs)
A: 新增全局Process缓存类 (Infrastructure/GlobalCaches/ProcessCache.cs) A: 新增WinDivert封装和PacketSniffer数据包捕获功能 (WinDivertNet/WinDivertWrapper) A: 新增Todo文档 (ClientApp/doc/Todo.md) U: 配置生成路由显示 (ClientApp/src/constants/app.ts) U: WebPanel新增数据包捕获触发逻辑 (Shell/Views/WebPanel.xaml.cs) U: 配置Shell项目加载WinDivert相关文件 (Shell/Shell.csproj)
This commit is contained in:
1 parent
078e59ae6b
commit
ad2514e044
21 files changed
+1560
-71
No files matched your search
@@ -0,0 +1,32 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Infrastructure.utils;
|
||||
|
||||
|
||||
public static class IconHelper
|
||||
{
|
||||
[DllImport("Shell32.dll", CharSet = CharSet.Auto)]
|
||||
private static extern IntPtr ExtractIcon(IntPtr hInst, string lpszExeFileName, int nIconIndex);
|
||||
|
||||
/// <summary>
|
||||
/// 获取 ICON
|
||||
/// </summary>
|
||||
/// <param name="exePath"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetIconBase64(string? exePath)
|
||||
{
|
||||
if (exePath == null && !File.Exists(exePath)) return "";
|
||||
IntPtr hIcon = ExtractIcon(IntPtr.Zero, exePath, 0);
|
||||
if (hIcon == IntPtr.Zero) return "";
|
||||
|
||||
using Icon icon = Icon.FromHandle(hIcon);
|
||||
using Bitmap bmp = icon.ToBitmap();
|
||||
using MemoryStream ms = new MemoryStream();
|
||||
// 保存为 PNG 格式
|
||||
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
|
||||
byte[] bytes = ms.ToArray();
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user