Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <stdafx.h>
- #include <windows.h>
- #include <iostream>
- using namespace std;
- wchar_t *c_to_w(char *c)
- {
- wchar_t *res = new wchar_t(strlen(c));
- mbstowcs(res, c, strlen(c));
- return res;
- }
- char *w_to_c(wchar_t *w)
- {
- char *res = new char(wcslen(w));
- wcstombs(res, w, wcslen(w));
- return res;
- }
- int FileSearch(LPWSTR Path = L"C:\\*.") //было бы не плохо автоматически Рабочий стол находить
- {
- WIN32_FIND_DATA fd;
- char *p = w_to_c(Path);
- HANDLE hf = FindFirstFile(p, &fd);
- delete p;
- if (hf != INVALID_HANDLE_VALUE)
- {
- do
- {
- LPWSTR dlim = L"\\";
- LPWSTR SubPath = c_to_w(fd.cFileName);
- wstring df = wstring(Path);
- df += dlim;
- df+=wstring(SubPath);
- LPWSTR DFl = &df[0];
- if (fd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
- {
- FileSearch(DFl);
- }
- else
- {
- char *buf = w_to_c(DFl);
- MessageBox(NULL, buf, "Поиск", MB_OKCANCEL);
- delete buf;
- }
- } while (FindNextFile(hf, &fd) != 0);
- FindClose(hf);
- }
- }
- int main()
- {
- FileSearch(L"C:\\*.");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment