如何获取特定文件夹的 shell 文件夹图标位置?

How to get the shell folder icon location for a specific folder?

在Delphi XE7 中,我需要获取Windows Explorer 用来显示文件夹的图标的位置,尤其是在缩略图视图中。所以我使用这个代码:

var
  Shell32DllFilePath: string;

// Get shell32.dll FilePath:
Shell32DllFilePath := IncludeTrailingPathDelimiter(JclSysInfo.GetWindowsSystemFolder) + 'shell32.dll';
if not FileExists(Shell32DllFilePath) then
begin
    Shell32DllFilePath := '';
    // Todo: log this error
end;

然后我假设默认文件夹图标是 shell32.dll 中带有 IconIndex 3 的图标:

但是,这为我提供了每个文件夹的静态图像,而 Windows Explorer 根据文件夹位置 and/or 文件夹内容使用不同的文件夹图标。

那么如何获得确切的文件夹图标位置(图标 dll 文件和图标索引)Windows Explorer 用于任何特定文件夹?

按照 Windows 的工作方式,可能没有指向图标的文件路径。您提到 "especially in thumbnail view",这意味着图像和图标(在文件夹内)在文件夹图标中堆叠在一起。这不会在任何地方保存文件,因此您无法从任何文件加载。

我假设这就是您所说的图标类型: