1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| void list_hd(char *szHD)
{
WIN32_FIND_DATA wfd;
DWORD dwLen, dwLenHD;
BOOL bTemp;
HANDLE hFile = FindFirstFileA(szHD, (LPWIN32_FIND_DATAA)&wfd);
dwLenHD = strlen(szHD) + 10;
if(hFile == INVALID_HANDLE_VALUE) {
fprintf(stderr, "GetLasError! %d\n\n", GetLastError());
return;
}
do {
if((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) {
dwLen = WideCharToMultiByte(CP_ACP, 0, wfd.cFileName, -1, NULL, 0, NULL, &bTemp);
LPSTR lpDir = new CHAR[dwLen];
LPSTR lpPath = new CHAR[dwLen+dwLenHD];
ZeroMemory(lpDir, dwLen);
ZeroMemory(lpPath, dwLen+dwLenHD);
WideCharToMultiByte(CP_ACP, 0, wfd.cFileName, -1, lpDir, dwLen, NULL, &bTemp);
sprintf(lpPath, "%s\b\b\b%s\\*.*", szHD, lpDir);
fprintf(stdout, "PATH: %s\n", lpPath);
list_hd(lpPath);
delete []lpDir;
delete []lpPath;
}
} while(FindNextFile(hFile, &wfd));
FindClose(hFile);
}
int main(int argc, char *argv[])
{
list_hd("C:\\");
return 0;
} |
Partager