系统图标-测试

This commit is contained in:
liufei
2021-12-23 17:58:06 +08:00
parent 09d3a520b4
commit e3a85e42fa
5 changed files with 370 additions and 1 deletions

34
Util/SystemIcon.cs Normal file
View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Util
{
public class SystemIcon
{
[DllImport("Shell32.dll")]
public static extern int ExtractIcon(IntPtr h, string strx, int ii);
public static Icon MyExtractIcon(string FileName, int iIndex, IntPtr h)
{
try
{
IntPtr hIcon = (IntPtr)ExtractIcon(h, FileName, iIndex);
if (!hIcon.Equals(null))
{
Icon icon = Icon.FromHandle(hIcon);
return icon;
}
}
catch (Exception ex)
{
}
return null;
}
}
}