: procedure GetChildFilesInfo(pPath: PAnsiChar);
var
FirstHandle: THandle;
InvalidHandleNo: Integer;
FIleCount:Integer;
DirCount:Integer;
IsExist: LongBool;
begin
InvalidHandleNo := 0;
FirstHandle := 0;
StrCat(pPath, '*');
ZeroMemory(@gFindData, SizeOf(WIN32_FIND_DATA));
begin
FirstHandle := FindFirstFile(pPath, gFindData);
if FirstHandle = INVALID_HANDLE_VALUE then
showmessage('无效句柄')
else
begin
//同下
if gFindData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY then
//如果是目录,记录
begin
StrLCopy(PChar(@DataFilesResult[i].DataFilePath), PChar(@gFindData.cFileName), MAX_PATH);
Inc(DirCount);
end
else
//如果是文件,详细记录
begin
StrLCopy(PChar(@DataFilesResult[i].DataFilePath), PChar(@gFindData.cFileName), MAX_PATH);
Inc(FileCount);
end
end;
while True do
begin
IsExist := FindNextFile(FirstHandle, gFindData);
if IsExist = False then
Break
else
begin
begin
//注意此处,gFindData.dwFileAttributes的值,出现过16,22,32。
//据windows下的定义,不会出现22才对。只能是2的n此方。。一直郁闷
//求高人帮忙,或者大家看代码那块不对。
if gFindData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY then
//如果是目录,记录
begin
StrLCopy(PChar(@DataFilesResult[i].DataFilePath), PChar(@gFindData.cFileName), MAX_PATH);
Inc(DirCount);
end
else
//如果是文件,记录
begin
StrLCopy(PChar(@DataFilesResult[i].DataFilePath), PChar(@gFindData.cFileName), MAX_PATH);
Inc(FileCount);
end
end;
end
end;
end
end;