找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
查看: 75|回复: 1

[分享] 从系统内置图标库中获取图标索引号

  [复制链接]
发表于 昨天 23:03 | 显示全部楼层 |阅读模式
本帖最后由 redyear2026 于 2026-7-27 23:35 编辑

用 bat+powershell 脚本获取 c:\Windows\System32\shell32.dll 或 c:\Windows\System32\imageres.dll 包含的图标索引号,代码预设路径是前者,若改为后者,可在代码第4行自行替换...

test.bat
  1. <# ::
  2. @echo off &powershell -nop -c "iex(${%~f0}|out-string)" &pause&exit/b
  3. #>
  4. $n=0; $maxP=260; $lib='c:\Windows\System32\shell32.dll'
  5. $path=[Runtime.InteropServices.Marshal]::StringToBSTR($lib)
  6. $buf=New-Object Text.StringBuilder($lib, $maxP)
  7. Add-Type '
  8.    using System; using System.Runtime.InteropServices;
  9.    public class p {
  10.    [DllImport("shell32.dll", EntryPoint="PickIconDlg", CharSet=CharSet.Unicode)]
  11.    public static extern int picker(IntPtr h, [MarshalAs(UnmanagedType.LPWStr)] string path, uint maxPath, ref int index); } '
  12. $r=[p]::picker([IntPtr]::Zero, $buf, $maxP, [ref]$n)
  13. if ($r -ne 1) { exit }
  14. "图标库文件: $($buf.ToString())`n图标索引号: $n"; exit
复制代码





发表于 11 分钟前 | 显示全部楼层
很强大!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1|闽公网安备35020302032614号 )

GMT+8, 2026-7-28 01:19

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表