-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaths.c
More file actions
53 lines (40 loc) · 1.2 KB
/
paths.c
File metadata and controls
53 lines (40 loc) · 1.2 KB
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
49
50
51
52
53
/*
* Created on: Mar 31, 2020
* Author: github.com/skilo83
* Version: 1.2
*/
#include <windows.h>
#include <userenv.h>
#include <stdlib.h>
#include <stdio.h>
#define MAXPATH 900
#define DEFAULT_FONT_COLOR 7
int main(void){
WIN32_FIND_DATA lpFindFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
char pathBuf[MAXPATH];
int fResult = 0;
HANDLE hConsole = INVALID_HANDLE_VALUE;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
ZeroMemory(pathBuf, sizeof(pathBuf));
hFind = FindFirstFileA("*", &lpFindFileData);
do{
SetConsoleTextAttribute(hConsole, 11);
fResult = FindNextFileA(hFind, &lpFindFileData);
GetFullPathNameA(lpFindFileData.cFileName, sizeof(pathBuf), pathBuf, NULL);
if ((lpFindFileData.dwFileAttributes) & (FILE_ATTRIBUTE_DIRECTORY == 16)){
SetConsoleTextAttribute(hConsole, 12);
}
if (lpFindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY){
SetConsoleTextAttribute(hConsole, 12);
}
if (fResult != 0){
printf("%s\n", pathBuf);
}
ZeroMemory(pathBuf, sizeof(pathBuf));
} while (fResult != 0);
SetConsoleTextAttribute(hConsole, DEFAULT_FONT_COLOR);
CloseHandle(hConsole);
FindClose(hFind);
return 0;
}