SHFILEINFO&&SHGetFileInfo

MFC文件之SHGetFileInfo函数与SHFILEINFO结构体 文章目录SHFILEINFO 结构体作用:定义成员SHGetFileInfo函数作用:函数原型参数 SHFILEINFO 结构体 作用: SHFILEINFO包含一个文件的信息。 定义 typedef struct _SHFILEINFO { HICON hIcon; int iIcon; DWORD dwAttributes; char szDisplayName[MAX_PATH]; char szTypeName[80]; } SHFILEINFO; 成员 hIcon:代表文件的图标的句 阅读详情
SHFILEINFO fileInfo;
SHGetFileInfo (
    "C://boot.ini", NULL,
    &fileInfo,
    sizeof(SHFILEINFO),
    SHGFI_ICON|SHGFI_TYPENAME);
 
cout << fileInfo . szTypeName << " 文件 " << endl ;
cout << "0x" << hex << fileInfo . hIcon << endl ;
cout << "0x" << hex << fileInfo . dwAttributes << endl ;
 
/*  输出:
    配置设置文件
    0x09FC07B5
    0x40400177
*/
 
//Handle to the icon that represents the file.
//You are responsible for destroying this handle
//with DestroyIcon when you no longer need it.
DestroyIcon ( fileInfo . hIcon );
______________________________
SHFILEINFO Structure----Contains information about a file object.
typedef struct _SHFILEINFO {
  HICON hIcon;
  int   iIcon;
  DWORD dwAttributes;
  TCHAR szDisplayName[MAX_PATH];
  TCHAR szTypeName[80];
} SHFILEINFO;

Members

hIcon

Type: HICON

A handle to the icon that represents the file. You are responsible for destroying this handle with DestroyIcon when you no longer need it.

 

iIcon

Type: int

The index of the icon image within the system image list.

 

dwAttributes

Type: DWORD

An array of values that indicates the attributes of the file object. For information about these values, see the IShellFolder::GetAttributesOf method.

 

szDisplayName

Type: TCHAR[MAX_PATH]

A string that contains the name of the file as it appears in the Windows Shell, or the path and file name of the file that contains the icon representing the file.

 

szTypeName

Type: TCHAR[80]

A string that describes the type of file.

----------------------------------------------

SHGetFileInfo Function

Retrieves information about an object in the file system, such as a file, folder, directory, or drive root.

 

DWORD_PTR SHGetFileInfo(
  __in     LPCTSTR pszPath,
  DWORD dwFileAttributes,
  __inout  SHFILEINFO *psfi,
  UINT cbFileInfo,
  UINT uFlags
);

 

pszPath [in]

Type: LPCTSTR

A pointer to a null-terminated string of maximum length MAX_PATH that contains the path and file name. Both absolute and relative paths are valid.

If the uFlags parameter includes the SHGFI_PIDL flag, this parameter must be the address of an ITEMIDLIST (PIDL) structure that contains the list of item identifiers that uniquely identifies the file within the Shell's namespace. The PIDL must be a fully qualified PIDL. Relative PIDLs are not allowed.

If the uFlags parameter includes the SHGFI_USEFILEATTRIBUTES flag, this parameter does not have to be a valid file name. The function will proceed as if the file exists with the specified name and with the file attributes passed in the dwFileAttributes parameter. This allows you to obtain information about a file type by passing just the extension for pszPath and passing FILE_ATTRIBUTE_NORMAL in dwFileAttributes.

This string can use either short (the 8.3 form) or long file names.

 

dwFileAttributes

Type: DWORD

A combination of one or more file attribute flags (FILE_ATTRIBUTE_ values as defined in Winnt.h). If uFlags does not include the SHGFI_USEFILEATTRIBUTES flag, this parameter is ignored.

psfi [in, out]

Type: SHFILEINFO*

Pointer to a SHFILEINFO structure to receive the file information.

 

cbFileInfo

Type: UINT

The size, in bytes, of the SHFILEINFO structure pointed to by the psfi parameter.

 

uFlags

Type: UINT

The flags that specify the file information to retrieve. This parameter can be a combination of the following values.

SHGFI_ADDOVERLAYS (0x000000020)

Version 5.0. Apply the appropriate overlays to the file's icon. The SHGFI_ICON flag must also be set.

SHGFI_ATTR_SPECIFIED (0x000020000)

Modify SHGFI_ATTRIBUTES to indicate that the dwAttributes member of the SHFILEINFO structure at psfi contains the specific attributes that are desired. These attributes are passed to IShellFolder::GetAttributesOf. If this flag is not specified, 0xFFFFFFFF is passed to IShellFolder::GetAttributesOf, requesting all attributes. This flag cannot be specified with the SHGFI_ICON flag.

SHGFI_ATTRIBUTES (0x000000800)

Retrieve the item attributes. The attributes are copied to the dwAttributes member of the structure specified in the psfi parameter. These are the same attributes that are obtained from IShellFolder::GetAttributesOf.

SHGFI_DISPLAYNAME (0x000000200)

Retrieve the display name for the file. The name is copied to the szDisplayName member of the structure specified in psfi. The returned display name uses the long file name, if there is one, rather than the 8.3 form of the file name.

SHGFI_EXETYPE (0x000002000)

Retrieve the type of the executable file if pszPath identifies an executable file. The information is packed into the return value. This flag cannot be specified with any other flags.

SHGFI_ICON (0x000000100)

Retrieve the handle to the icon that represents the file and the index of the icon within the system image list. The handle is copied to the hIcon member of the structure specified by psfi, and the index is copied to the iIcon member.

SHGFI_ICONLOCATION (0x000001000)

Retrieve the name of the file that contains the icon representing the file specified by pszPath, as returned by the IExtractIcon::GetIconLocation method of the file's icon handler. Also retrieve the icon index within that file. The name of the file containing the icon is copied to the szDisplayName member of the structure specified by psfi. The icon's index is copied to that structure's iIcon member.

SHGFI_LARGEICON (0x000000000)

Modify SHGFI_ICON, causing the function to retrieve the file's large icon. The SHGFI_ICON flag must also be set.

SHGFI_LINKOVERLAY (0x000008000)

Modify SHGFI_ICON, causing the function to add the link overlay to the file's icon. The SHGFI_ICON flag must also be set.

SHGFI_OPENICON (0x000000002)

Modify SHGFI_ICON, causing the function to retrieve the file's open icon. Also used to modify SHGFI_SYSICONINDEX, causing the function to return the handle to the system image list that contains the file's small open icon. A container object displays an open icon to indicate that the container is open. The SHGFI_ICON and/or SHGFI_SYSICONINDEX flag must also be set.

SHGFI_OVERLAYINDEX (0x000000040)

Version 5.0. Return the index of the overlay icon. The value of the overlay index is returned in the upper eight bits of the iIcon member of the structure specified by psfi. This flag requires that the SHGFI_ICON be set as well.

SHGFI_PIDL (0x000000008)

Indicate that pszPath is the address of an ITEMIDLIST structure rather than a path name.

SHGFI_SELECTED (0x000010000)

Modify SHGFI_ICON, causing the function to blend the file's icon with the system highlight color. The SHGFI_ICON flag must also be set.

SHGFI_SHELLICONSIZE (0x000000004)

Modify SHGFI_ICON, causing the function to retrieve a Shell-sized icon. If this flag is not specified the function sizes the icon according to the system metric values. The SHGFI_ICON flag must also be set.

SHGFI_SMALLICON (0x000000001)

Modify SHGFI_ICON, causing the function to retrieve the file's small icon. Also used to modify SHGFI_SYSICONINDEX, causing the function to return the handle to the system image list that contains small icon images. The SHGFI_ICON and/or SHGFI_SYSICONINDEX flag must also be set.

SHGFI_SYSICONINDEX (0x000004000)

Retrieve the index of a system image list icon. If successful, the index is copied to the iIcon member of psfi. The return value is a handle to the system image list. Only those images whose indices are successfully copied to iIcon are valid. Attempting to access other images in the system image list will result in undefined behavior.

SHGFI_TYPENAME (0x000000400)

Retrieve the string that describes the file's type. The string is copied to the szTypeName member of the structure specified in psfi.

SHGFI_USEFILEATTRIBUTES (0x000000010)

Indicates that the function should not attempt to access the file specified by pszPath. Rather, it should act as if the file specified by pszPath exists with the file attributes passed in dwFileAttributes. This flag cannot be combined with the SHGFI_ATTRIBUTES, SHGFI_EXETYPE, or SHGFI_PIDL flags.

Return Value

Type: DWORD_PTR

Returns a value whose meaning depends on the uFlags parameter.

If uFlags does not contain SHGFI_EXETYPE or SHGFI_SYSICONINDEX, the return value is nonzero if successful, or zero otherwise.

If uFlags contains the SHGFI_EXETYPE flag, the return value specifies the type of the executable file. It will be one of the following values.

 

 

Return code--------------------------------------------------------------------Description

 

0

Nonexecutable file or an error condition.

LOWORD = NE or PE and HIWORD = Windows version

Windows application.

LOWORD = MZ and HIWORD = 0

MS-DOS .exe or .com file

LOWORD = PE and HIWORD = 0

Console application or .bat file


深入掌握如何获取Windows文件系统图标 本文还有配套的精品资源,点击获取 简介:在Windows操作系统中,文件系统图标用于图形化表示文件、文件夹或驱动器。这些图标可以动态加载并在用户界面元素如资源管理器、桌面快捷方式中显示。文章将探讨如何编程获取这些图标,特别通过动态加载系统文件目录并获取系统文件夹图标的方法。介绍关键的Windows API函数如SHGetFileInfo、SHFILEINFO、LoadIco... 阅读详情

相关推荐

Arm Neoverse CMN-700 QoS与PrefetchTarget架构解析

在现代多核处理器系统中,内存访问性能优化是提升整体效能的关键。QoS(服务质量)技术通过优先级调控机制,确保关键任务获得更高的缓存带宽和内存访问权限。PrefetchTarget作为预取技术的一种实现,能够显著降低内存访问延迟,特别适用于AI训练和数据库系统等高性能计算场景。Arm Neoverse CMN-700通过RN SAM模块实现了硬件级的地址范围检测和优先级调控,支持最多8个独立内存区域的QoS配置。测试数据显示,合理配置QoS可使关键任务延迟降低40%,而PrefetchTarget技术则能减少

weixin_36197669的博客 321

Qt HICON to QPixmap 调用winapi 获取windows文件图标转换为QPixmap

Qt获取windows文件图标转换为QPixmap

sevendemage的博客 898

mos管结电容等效模型_MOS管的防冲击防反接电路

MOS管的反接和抑制冲击一:原理分析MOS管由于生产工艺等因素,会产生相应的寄生电容,体二极管等。Mos管的寄生电容如图1所示,可以看到其具有三个寄生电容:G和S的电容Cgs;G和D的电容:Cgd,也称为反向传输电容、米勒电容、Crss;D和S的电容Cds。D和S之间的体二极管D1.图 1:MOS管等效模型寄生电容的数值可以从元器件的datasheet中得到,如图2,图3:Ciss(输入电容)=C...

weixin_29179583的博客 1864

Windows Shell 编程 第四章

 http://blog.csdn.net/Comman1999/archive/2008/07/03/2608967.aspx以前,所有文件和目录都有一个确定的属性集:时间,日期,尺寸,以及表示‘只读的’,‘隐藏的,‘存档的’,或‘系统的’状态标志。然而,Windos95(及后来的WindowsNT4.0)出现使这些概念产生了改变,其中最重要的‘文件’变得更加广泛。现在,文件可以

1163

数据仓库建模的步骤-从需求分析到模型优化的全面指南

数据仓库建模是一个系统化的过程,旨在设计和构建一个高效、可扩展的数据存储和分析环境。它的目标是将来自不同源系统的数据整合到一个统一的、面向主题的、随时间变化的数据集合中,以支持企业的决策制定过程。数据仓库建模不仅仅是创建表格和定义关系,它更是一门艺术,需要平衡业务需求、技术限制和未来的可扩展性。提供快速的查询性能支持复杂的分析需求适应业务的变化和增长保持数据的一致性和准确性接下来,让我们深入探讨数据仓库建模的每个主要步骤。

一个8年大数据开发工程师的碎碎念 2117

简易背单词系统C/C++

#include&lt;stdio.h&gt; #include&lt;string.h&gt; int F=20,N=100,k=0; int score[100]; int count=0; void hello(); void add(); void preview(); void mdelete(); void etc(); void cte(); void mscore(); void...

青木年华 9157

11

///     /// SHFILEINFO系统API,包含一个文件的信息     ///     [StructLayout(LayoutKind.Sequential)]     public struct SHFILEINFO     {         public IntPtr hIcon;                                   //图标句柄

343

ESP32S3新手避坑:用IDF5.0驱动GT911触摸屏,我踩过的三个雷都给你填平了

本文详细解析了在ESP32S3开发板上使用IDF5.0驱动GT911触摸屏时常见的三大问题:软重启失效、状态寄存器读取异常和初始化参数差异。通过逻辑分析和硬件调试工具,提供了针对性的解决方案和优化建议,帮助开发者高效完成触摸屏驱动开发。

weixin_42567497的博客 300

在C#使用SHGetFileInfo获取(管理)文件或者文件夹图标(C#封装Win32函数的一个例子)

如果没有,你就获得到一个难看的黑色边框。第一,它分割了文件的路径以得到文件的扩展名(扩展名是“.”后面的那部分,也是数组的最大位置上的字符串)。一旦我拥有了一个用来取得文件图标的必要API函数,我就建立另一个类型来管理大小图象列表,这能使我能够通过一个单独的调用来添加图标,如果它已经被加进来了,就返回这个图标在ImageList里的索引。不过作者提供的类还是不能满足我的所有需要,那就是不能获得软驱跟光驱的图标,然后特别纳闷的是我最先用的MSDN的代码可以得到这些图标,然后我比较了半天都没看出什么名堂来。

biyusr的专栏 1124

OTFS 消息传递算法信号检测【附matlab代码详解】

OTFS 消息传递算法方面的一些浅浅理解。

Cuby的博客 4016

【Claude Code】Unable to connect to API 报错原因与排查解决全流程

深入分析 Claude Code 中 Unable to connect to API 系列报错的根因,涵盖 ECONNREFUSED、ECONNRESET、ETIMEDOUT 等 6 种变体,提供从网络连通性检测、代理配置到 LLM 网关路由的完整排查路径,帮助开发者快速恢复 Claude Code 的正常使用。

多媒体编程、网络编程、系统编程、网络安全编程、驱动编程 2863

用SHGetFileInfo函数获取文件信息

SHGetFileInfo函数 WINSHELLAPI DWORD WINAPI SHGetFileInfo( LPCTSTR pszPath, DWORD dwFileAttributes, SHFILEINFO FAR *psfi, UINT cbFileInfo, UINT uFlags ); SHGetFileInfo的定义 MSDN上的定义是: Retrieves information about an object in th...

甜筒八部 的专栏 1803

【实战项目开发技术分享】如何设置机器人禁行区/虚拟墙

在现代机器人技术的日益发展中,路径规划是使机器人在复杂环境中安全、高效移动的关键部分。其中一个重要的问题是如何划定机器人的禁行区,以确保机器人不会进入危险区域或无法到达的地方。在本文中,我们将探讨一些关键策略,帮助机器人算法工程师更好地划定禁行区。代价地图可以通过多层叠加来实现,一般包括以下几个层级:静态地图层(Static Map Layer):由SLAM(Simultaneous Localization and Mapping)构建的静态地图。该层包含了环境中固定不变的地物信息,如墙壁、家具等。

xiewf的博客 1万+

SHGetFileInfo()获取系统图标方法

头文件 /// @class CSHGetFileInfo /// SHGetFileInfo的包裹类 class CSHGetFileInfo { public: CSHGetFileInfo(); virtual ~CSHGetFileInfo(); /// 获取系统图像列表 /// @param[in] bSmallIcon ture则为小图标,false则为大图标 HIMAGELIST ...

qq_42840244的博客 3211

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

SHGetFileInfo函数

SHGetFileInfo Function Retrieves information about an object in the file system, such as a file, folder, directory, or drive root. 获得一个文件系统对象的信息,如一个文件、文件夹、目录或者根驱动器等的信息 语法(Syntax) DWORD_PTR SHGet

JohnnyHu90的专栏 1579

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

文件的本质--SHGetFileInfo()

本文从一下几个方法进行介绍:  SHGetFileInfo的定义 SHGetFileInfo()函数的工作原理 SHGetFileInfo()函数的返回值 SHGetFileInfo()函数的简单示例  SHGetFileInfo的定义        SHGetFileInfo在MSDN上的定义是: Retrieves information about an object

IT民工 4925

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

SHGetFileInfo

SHGetFileInfo用于获取文件,文件夹,或者磁盘的信息 用法:  SHFILEINFO info = {0};  SHGetFileInfo("D:\\book",0,&info,sizeof(info),SHGFI_TYPENAME|SHGFI_DISPLAYNAME|SHGFI_ICON);   SHGFI_TYPENAME 获取类型信息,比如 文件夹   S

最爱吹吹风 1692

【MoreWindows工作笔记4】 获取文件图标 类型名称 属性 SHGetFileInfo

【MoreWindows工作笔记4】 获取文件图标 类型名称 属性 SHGetFileInfo

weixin_43417960的博客 308

SHGetFileInfo函数详解

SHGetFileInfo函数function SHGetFileInfo(pszPath: PAnsiChar; dwFileAttributes: DWORD;  var psfi: TSHFileInfo; cbFileInfo, uFlags: UINT): DWORD; stdcall;pszPath 参数:指定的文件名。 当uFlags的取值中不包含 SHGFI_PIDL时,可直接

狂疯庵Blog 1944

使用SHGetFileInfo函数获取任何文件大图标

为了实现在vista和更高版本的系统中能够获取任何文件的大图标(48*48像素,甚至256*256像素),真是找了很多资料,最终经过朋友的帮忙找到了实现方法。    网络中有很多获取exe大图标的方法,可惜不能获取所有文件的,有使用ExtractIcon函数也有介绍使用注册表实现的,经过仔细测试,最终采用SHGetFileInfo函数。SHGetFileInfo的使用方法网上资料很多,但是真正能

yueyun889的专栏 4882

SHGetFileInfo(获取文件信息)

可以获取文件系统中的文件、目录、驱动器的信息。 语法: WINSHELLAPI DWORD WINAPI SHGetFileInfo( LPCTSTR pszPath, DWORD dwFileAttributes, SHFILEINFO FAR* psfi, UINT cbFileInfo, UINT uFlags ); 参数: [in]

易元——美好吧 2284

error C2061: syntax error : identifier 'SHFILEINFOW' // 无法解析的外部符号 wWinMain,该符号在函数 WinMainCRTStartup

1>StdAfx.cpp 1>E:\Program Files\Windows CE Tools\wce600\DbAu13xx\include\MIPSII\shellapi.h(321) : error C2061: syntax error : identifier 'SHFILEINFOW' 1>C:\Program Files\Microsoft Visual Studio 8\VC

chenyujing1234的专栏 3887

VC API常用函数简单例子大全

VC API常用函数简单例子大全 http://hi.baidu.com/tag/vc%20api%E5%87%BD%E6%95%B0/feeds   系统API查询 http://www.vbgood.com/api.html http://hi.baidu.com/3582077/item/9cc3483b581f53c5392ffae3 第一个:FindWindow根据窗口类

jiangxinyu的专栏 5382
上一篇: GetWindowRect&GetClientRect&MoveWindow()
下一篇: strtok()--SelectItem--HitTest
丸子头
博客等级 码龄18年 43粉丝 32原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值