如何使用批处理脚本在 windows 上查找软件图标

how to find a software icon on windows using batch script

我正在做一个小的 c 项目,它是一个包含所有内容的菜单
用户拥有的程序。 所以我需要一个批处理脚本

不是不可能完成的任务(毕竟,Windows做到了!)。通常,程序的图标在两个位置之一指定:在程序二进制文件本身内,或在程序的快捷方式中。

  • 在程序二进制文件中: Windows 程序(EXE 和 DLL)使用一种称为 Portable Executable (PE) format. This file format specifies the organization of code and data for programs. Icons would be stored somewhere in here. So, you would need to parse the PE format in order to get the icon. Thankfully, it looks like Windows provides a function for getting icons: ExtractIconEx. You might use this to get an icon from a program. Here's 的格式,我在一篇文章中发现对该功能有一些评论。其中一些链接已失效--Google 是你最好的朋友。

  • 在快捷方式中: Here 是一个已经回答的关于从快捷方式获取图标的 Whosebug 问题。里面的东西可能会有帮助。

一些补充意见:

  • 在 Program Files 目录中查找每个 EXE 将是缓慢且无用的。里面有很多没人想用的程序。您要做的是解析“开始”菜单文件夹中的快捷方式。
  • 从那里,您需要从快捷方式获取图标。如果失败,请从程序本身获取它。

希望对您有所帮助。