网站首页  词典首页

请输入您要查询的函数:

 

术语 shgetfileinfo
释义 SHGetFileInfo
语法:
DWORD_PTR SHGetFileInfo( LPCTSTR pszPath,
DWORD dwFileAttributes,
SHFILEINFO *psfi,
UINT cbFileInfo,
UINT uFlags
);
SHGetFileInfo函数
信息检索中的一个文件系统对象,如文件,文件夹,目录或驱动器的根。
参数
pszPath
[in]指向一个NULL结尾的最大长度MAX_PATH,它包含的路径和文件名字符串。绝对和相对路径是否有效。
如果uFlags参数包括SHGFI_PIDL标志,这个参数必须是一个ITEMIDLIST(的PIDL地址)结构,它包含的项目标识符列表唯一标识在壳牌的命名空间的文件。在一个项目标识符列表(的PIDL)指针必须是一个完全合格的PIDL。相对PIDLs都是不允许的。
如果uFlags参数包括SHGFI_USEFILEATTRIBUTES国旗,此参数不必须是有效的文件名。该函数将如期如果该文件具有指定名称和属性的文件存在,在dwFileAttributes参数传递。这使您可以获取有关在dwFileAttributes传递只是延长pszPath和通过FILE_ATTRIBUTE_NORMAL文件类型信息。
该字符串可以使用短(8.3形式)或长文件名。
dwFileAttributes
[in]的一个或多个文件的属性标志的组合(FILE_ATTRIBUTE_值定义在WINNT.H)。如果uFlags不包括SHGFI_USEFILEATTRIBUTES标志,这个参数被忽略。
psfi
[指出]一个SHFILEINFO结构的地址,以接收该文件的信息。
cbFileInfo
[in]的大小,以字节指出,在SHFILEINFO结构由psfi参数。
uFlags
[in]的标志指定文件信息检索。此参数可以是下列值的组合。
SHGFI_ADDOVERLAYS
5.0版本。应用适当的覆盖到文件的图标。该SHGFI_ICON标志也必须设置。
SHGFI_ATTR_SPECIFIED
修改SHGFI_ATTRIBUTES表明,该SHFILEINFO结构dwAttributes在psfi成员包含所期望的特定属性。这些属性传递给IShellFolder::GetAttributesOf。如果此标志没有被指定,0xFFFFFFFF是传递给IShellFolder::GetAttributesOf,要求所有属性。这个标志不能指定与SHGFI_ICON标志。
SHGFI_ATTRIBUTES
检索项属性。的属性复制到在psfi参数中指定的结构dwAttributes成员。这些,同时是从IShellFolder得到属性::GetAttributesOf。
SHGFI_DISPLAYNAME
检索该文件的显示名称。这个名字被复制到指定的psfi结构szDisplayName成员。返回的显示名称使用长文件名,如果有一个而不是8.3的文件名形式。
SHGFI_EXETYPE
检索可执行文件的类型,如果pszPath标识一个可执行文件。这些信息装在返回值。这个标志不能指定任何其他标志。
SHGFI_ICON
检索处理的图标,表示文件和系统内的图像列表图标的索引。句柄复制到指定的psfi hIcon成员的结构,索引被复制到iIcon成员。
SHGFI_ICONLOCATION
检索的文件包含的图标代表的pszPath指定的文件,由IExtractIcon返回::GetIconLocation的文件的图标处理方法的名称。另外在该文件中提取图标索引。在包含该图标文件名复制到指定的psfi结构szDisplayName成员。该图标的指数复制到该结构的iIcon成员。
SHGFI_LARGEICON
修改SHGFI_ICON,导致函数来检索文件的大图标。该SHGFI_ICON标志也必须设置。
SHGFI_LINKOVERLAY
修改SHGFI_ICON,导致功能将链接添加覆盖到文件的图标。该SHGFI_ICON标志也必须设置。
SHGFI_OPENICON
修改SHGFI_ICON,导致函数来检索文件的打开图标。也用于修改SHGFI_SYSICONINDEX,导致函数返回的句柄系统图像列表,其中包含该文件的小规模开放型图标。一个容器对象显示一个开放的图标显示,容器是开放的。在SHGFI_ICON和/或SHGFI_SYSICONINDEX标志也必须设置。
SHGFI_OVERLAYINDEX
5.0版本。返回索引覆盖图标。该指数值覆盖返回上游8个指定由psfi结构iIcon成员位。此标志要求该SHGFI_ICON设置也。
SHGFI_PIDL
表明pszPath是一个ITEMIDLIST结构的地址,而不是一个路径名。
SHGFI_SELECTED
修改SHGFI_ICON,导致功能融入系统突出显示颜色的文件的图标。该SHGFI_ICON标志也必须设置。
SHGFI_SHELLICONSIZE
修改SHGFI_ICON,导致函数检索壳牌公司的大小图标。如果这个标志不指定大小的图标功能根据系统指标值。该SHGFI_ICON标志也必须设置。
SHGFI_SMALLICON
修改SHGFI_ICON,导致函数来检索文件的小图标。也用于修改SHGFI_SYSICONINDEX,导致函数返回的句柄系统图像列表,其中包含小图标图像。在SHGFI_ICON和/或SHGFI_SYSICONINDEX标志也必须设置。
SHGFI_SYSICONINDEX
检索系统的图像列表图标索引。如果成功,该指数是复制到psfi iIcon成员。返回值是一个句柄系统图像列表。只有那些指数成功地复制到iIcon图像是有效的。试图访问系统中的图像列表的照片会导致不确定的行为。
SHGFI_TYPENAME
检索字符串,描述该文件的类型。该字符串复制到指定的psfi结构szTypeName成员。
SHGFI_USEFILEATTRIBUTES
表明该函数不应该试图访问pszPath指定的文件。相反,它要充当如果pszPath指定的文件存在属性dwFileAttributes通过了该文件。这标志不能结合SHGFI_ATTRIBUTES,SHGFI_EXETYPE,或SHGFI_PIDL旗帜。
返回值
返回一个值,其意义就uFlags参数而定。
如果uFlags不包含SHGFI_EXETYPE或SHGFI_SYSICONINDEX,返回值为非零如果成功,或否则为0。
如果uFlags包含SHGFI_EXETYPE标志,返回值指定可执行文件的类型。这将是下列值之一。
0Nonexecutable文件或错误条件。
LOWORD =东北或PE和HIWORD =视窗versionMicrosoft Windows应用程序。
LOWORD =锰锌和HIWORD = 0Windows 95,视窗98:微软的MS - DOS的。exe,。com或。bat文件
微软的Windows NT,Windows 2000中,Windows XP中:MS - DOS的。exe或。com文件
LOWORD = PE和HIWORD = 0Windows 95,视窗98:微软Win32控制台应用程序
Windows NT中,Windows 2000中,Windows XP中:Win32控制台应用程序或。bat文件
备注
如果SHGetFileInfo返回图标句柄在SHFILEINFO结构hIcon成员指向psfi,您有责任与DestroyIcon它释放时,您不再需要它。
注意:一旦您有一个句柄系统图像列表,您可以使用图像列表API来操作像任何其他图片列表。因为系统图像列表上每个进程的基础上创建的,您应该把他们作为只读的对象。写入系统图像列表可能会覆盖或删除系统的图像之一,它用或不正确的改革进程其他决策。
您必须初始化CoInitialize或OleInitialize的组件对象模型(COM)之前调用SHGetFileInfo。
当您使用Windows应用程序的SHGFI_EXETYPE标志,Windows版本的可执行文件,是在给返回值HIWORD。此版本是返回为一个十六进制值。就等同于一个特定的Windows版本这个值的详情,请参阅使用SDK头文件。
视窗95,视窗98,Windows Millennium版本(Windows Me)中:SHGetFileInfo是支持的Unicode(MSLU)微软层。要使用此,您必须将某些文件到您的应用,概述了对Unicode的Microsoft层在Windows 95/98系统。
例如
下面的代码示例使用SHGetFileInfo来检索回收站显示名称,其的PIDL确定。
LPITEMIDLIST pidl = NULL;
hr = SHGetFolderLocation(NULL, CSIDL_BITBUCKET, NULL, 0, &pidl);
if (SUCCEEDED(hr))
{
SHFILEINFOW sfi = {0};
hr = SHGetFileInfo((LPCTSTR)pidl,
-1,
&sfi,
sizeof(sfi),
SHGFI_PIDL | SHGFI_DISPLAYNAME)

if (SUCCEEDED(hr))
{
// The display name is now held in sfi.szDisplayName.
}
}
ILFree(pidl);

功能信息
最低DLL版本 shell32.dll 4.0或更高版本
自定义ImplementationNo
Headershellapi.h
import libraryshell32.lib
最低经营systemsWindows NT 4.0中,Windows 95中
UnicodeImplemented为ANSI和Unicode版本。
参见
FileIconInit
==英文原文==SHGetFileInfo Function
Retrieves information about an object in the file system, such as a file, folder, directory, or drive root.
Syntax
DWORD_PTR SHGetFileInfo( LPCTSTR pszPath,
DWORD dwFileAttributes,
SHFILEINFO *psfi,
UINT cbFileInfo,
UINT uFlags
);
Parameters
pszPath
[in] 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 pointer to an item identifier list (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
[in] 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
[out] The address of a SHFILEINFO structure to receive the file information.
cbFileInfo
[in] The size, in bytes, of the SHFILEINFO structure pointed to by the psfi parameter.
uFlags
[in] The flags that specify the file information to retrieve. This parameter can be a combination of the following values.
SHGFI_ADDOVERLAYS
Version 5.0 . Apply the appropriate overlays to the file's icon. The SHGFI_ICON flag must also be set.
SHGFI_ATTR_SPECIFIED
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
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
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
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
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
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
Modify SHGFI_ICON, causing the function to retrieve the file's large icon. The SHGFI_ICON flag must also be set.
SHGFI_LINKOVERLAY
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
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
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
Indicate that pszPath is the address of an ITEMIDLIST structure rather than a path name.
SHGFI_SELECTED
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
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
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
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
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
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
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.
0Nonexecutable file or an error condition.
LOWORD = NE or PE and HIWORD = Windows versionMicrosoft Windows application.
LOWORD = MZ and HIWORD = 0Windows 95, Windows 98: Microsoft MS-DOS .exe, .com, or .bat file
Microsoft Windows NT, Windows 2000, Windows XP: MS-DOS .exe or .com file
LOWORD = PE and HIWORD = 0Windows 95, Windows 98: Microsoft Win32 console application
Windows NT, Windows 2000, Windows XP: Win32 console application or .bat file
Remarks
If SHGetFileInfo returns an icon handle in the hIcon member of the SHFILEINFO structure pointed to by psfi, you are responsible for freeing it with DestroyIcon when you no longer need it.
Note Once you have a handle to a system image list, you can use the Image List API to manipulate it like any other image list. Because system image lists are created on a per-process basis, you should treat them as read-only objects. Writing to a system image list may overwrite or delete one of the system images, making it unavailable or incorrect for the remainder of the process.
You must initialize Component Object Model (COM) with CoInitialize or OleInitialize prior to calling SHGetFileInfo.
When you use the SHGFI_EXETYPE flag with a Windows application, the Windows version of the executable is given in the HIWORD of the return value. This version is returned as a hexadecimal value. For details on equating this value with a specific Windows version, see Using the SDK Headers .
Windows 95,Windows 98,Windows Millennium Edition (Windows Me): SHGetFileInfo is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows Me/98/95 Systems .
Example
The following code example uses SHGetFileInfo to retrieve the display name of the Recycle Bin, identified by its PIDL.
LPITEMIDLIST pidl = NULL;
hr = SHGetFolderLocation(NULL, CSIDL_BITBUCKET, NULL, 0, &pidl);
if (SUCCEEDED(hr))
{
SHFILEINFOW sfi = {0};
hr = SHGetFileInfo((LPCTSTR)pidl,
-1,
&sfi,
sizeof(sfi),
SHGFI_PIDL | SHGFI_DISPLAYNAME)

if (SUCCEEDED(hr))
{
// The display name is now held in sfi.szDisplayName.
}
}
ILFree(pidl);
Function Information
Minimum DLL Versionshell32.dll version 4.0 or later
Custom ImplementationNo
Headershellapi.h
Import libraryshell32.lib
Minimum operating systemsWindows NT 4.0, Windows 95
UnicodeImplemented as ANSI and Unicode versions.
See Also
FileIconInit
==原始网址==http://msdn.microsoft.com/en-us/library/bb762179(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:15:28