我已经调试过了,但我仍然不知道可能是什么罪魁祸首。
#ifndef UNICODE
#define UNICODE
#endif
#include <stdio.h>
#include <Windows.h>
void EndWithBackslash(TCHAR* string)
{
if(string[wcslen(string)-1] != TEXT('\\')) wcscat(string,TEXT("\\"));
}
void Browse(const TCHAR* curdir)
{
HANDLE hFoundFile;
WIN32_FIND_DATA foundFileData;
TCHAR buffer[MAX_PATH];
wcscpy(buffer,curdir);
EndWithBackslash(buffer);
SetCurrentDirectory(buffer);
hFoundFile = FindFirstFileEx(TEXT("*"),FINDEX_INFO_LEVELS::FindExInfoBasic,&foundFileData ,FINDEX_SEARCH_OPS::FindExSearchLimitToDirectories ,NULL , NULL);
if(hFoundFile != INVALID_HANDLE_VALUE)
{
do
{
if ((foundFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && wcscmp(foundFileData.cFileName,TEXT(".")) && wcscmp(foundFileData.cFileName,TEXT("..")) )
{
EndWithBackslash(buffer);
wcscat(buffer,foundFileData.cFileName);
wprintf(TEXT("%s\n"),buffer);
Browse(buffer);
}
}
while(FindNextFile(hFoundFile,&foundFileData));
FindClose(hFoundFile);
}
}
int main(void)
{
Browse(TEXT("F:\\"));
system("Pause");
return 0;
}
输出:
F:\$RECYCLE.BIN
F:\$RECYCLE.BIN\S-1-5-21-1271883188-2384997935-49719322-1000
F:\$RECYCLE.BIN\希捷
F:\$RECYCLE.BIN\希捷\希捷Dashboard 2.0
F:\$RECYCLE.BIN\Seagate\Seagate Dashboard 2.0\System Volume Information
F:\$RECYCLE.BIN\Seagate\Seagate Dashboard 2.0\System Volume Information\Video
“第一层”到底长什么样:
你能指出我的错误吗?