大送分啦!!!!

cmsbai 2003-10-17 08:21:35
送分之前,先问各位大虾一个问题:
如何获取当前一个文件夹下的属性(文件的个数及各个文件名),VC+MFC实现?
...全文
75 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
gzshd 2003-10-18
  • 打赏
  • 举报
回复
csdn:
SHGetFileInfo


WINSHELLAPI DWORD WINAPI SHGetFileInfo(
LPCTSTR pszPath,
DWORD dwFileAttributes,
SHFILEINFO FAR *psfi,
UINT cbFileInfo,
UINT uFlags
);

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

Returns a value whose meaning depends on the uFlags parameter. 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: Value Executable File Type
0 Nonexecutable file or an error condition
LOWORD = NE or PE and HIWORD = 3.0, 3.5, or 4.0 Windows application
LOWORD = MZ and HIWORD = 0 MS-DOS .exe, .com, or .bat file
LOWORD = PE and HIWORD = 0 Win32 console application

If uFlags contains SHGFI_SYSICONINDEX, the return value is the handle to the system image list that contains the large icon images. If SHGFI_SMALLICON is included with SHGFI_SYSICONINDEX, the return value is the handle to the image list that contains the small icon images.

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

pszPath
Address of a buffer 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
Combination of one or more file attribute flags (FILE_ATTRIBUTE_ values). If uFlags does not include the SHGFI_USEFILEATTRIBUTES flag, this parameter is ignored.
psfi
Address of a SHFILEINFO structure to receive the file information.
cbFileInfo
Size, in bytes, of the SHFILEINFO structure pointed to by the psfi parameter.
uFlags
Flags that specify the file information to retrieve. This parameter can be a combination of the following values: SHGFI_ATTR_SPECIFIED Modifies SHGFI_ATTRIBUTES. Indicates that the dwAttributes member of the SHFILEINFO structure at psfi contains the specific attributes that are desired. These attributes will be passed to IShellFolder::GetAttributesOf. If this flag is not specified, 0xFFFFFFFF will be passed to 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. 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. The return value is the handle to the system image list.
SHGFI_ICONLOCATION Retrieve the name of the file that contains the icon representing the file. The name is copied to the szDisplayName member of the structure specified in psfi.
SHGFI_LARGEICON Modify SHGFI_ICON, causing the function to retrieve the file's large icon.
SHGFI_LINKOVERLAY Modify SHGFI_ICON, causing the function to add the link overlay to the file's icon.
SHGFI_OPENICON Modify SHGFI_ICON, causing the function to retrieve the file's open icon. A container object displays an open icon to indicate that the container is open.
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.
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.
SHGFI_SMALLICON Modify SHGFI_ICON, causing the function to retrieve the file's small icon.
SHGFI_SYSICONINDEX Retrieve the index of the icon within the system image list. The index is copied to the iIcon member of the structure specified by psfi. The return value is the handle to the system image list.
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.
vagabondkq 2003-10-18
  • 打赏
  • 举报
回复
up
紫郢剑侠 2003-10-18
  • 打赏
  • 举报
回复
gz

up
flyelf 2003-10-17
  • 打赏
  • 举报
回复
接分了
在windows中可以使用FindFirstFile、FindNextFile遍历得到一个文件下的文件
WIN32_FIND_DATA tFindFile = {0};
HADNDLE hFind = ::FindFirstFile("*.*", &tFindFile);
BOOL bFind = TRUE;
while(hFind && bFind)
{
// 处理找到的文件
bFind = ::FindNextFile(hFind, &tFindFile);
...
}
::FindClose(hFind);
akiko 2003-10-17
  • 打赏
  • 举报
回复
大接分啦!!!!
接分之后,你看看这里,把代码稍微裁减一下就行啦
http://www.vckbase.com/document/viewdoc.asp?id=806

2,586

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧