Trying to figure out WinAPI . You need to change the time for creating files in the folder to the current time, and then display the file names and date in the List Box . It was possible only to display the names of the files. Tried to change the date using SetFileTime() , but it does not change.

 WIN32_FIND_DATA FindFileData; HANDLE hf = FindFirstFile("\\*", &FindFileData); do { // Если не директория if(!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { // Вывод имени файла в ListBox SendDlgItemMessage( p->hDlg, IDC_LIST1, LB_ADDSTRING, NULL, (LPARAM)FindFileData.cFileName ); } } while(FindNextFile(hf,&FindFileData) != 0); FindClose(hf); 
  • > I tried to change the date using SetFileTime (), but it does not change. Show how you tried. - Here's your example: Changing a File Time to the Current Time - mega
  • BOOL SetFileToCurrentTime (HANDLE hFile) {FILETIME ft; SYSTEMTIME st; GetSystemTime (& st); // get the current time SystemTimeToFileTime (& st, & ft); // convert to file format return SetFileTime (hFile, // set the date / time of the file modification & ft, (LPFILETIME) NULL, (LPFILETIME) NULL); } - Vadim Yakushkin
  • strcat_s (dispname, "\ *"); WIN32_FIND_DATA FindFileData; HANDLE hf; hf = FindFirstFile (dispname, & FindFileData); do {// If not the if (! (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) directory) {SendDlgItemMessage (p-> hDlg, IDC_LIST1, LB_ADDSTRING, NULL, (LPARAM) FindFileData.cFileName); if (SetFileToCurrentTime (hf)) SendDlgItemMessage (p-> hDlg, IDC_LIST1, LB_ADDSTRING, NULL, (LPARAM) TEXT ("Done!")); }} while (FindNextFile (hf, & FindFileData)! = 0); FindClose (hf); - Vadim Yakushkin
  • > if (SetFileToCurrentTime (hf)) ... hf is not a file descriptor, hence the error. File descriptor returns CreateFile - mega
  • Added to the loop: hOF = (HANDLE) CreateFile (FindFileData.cFileName, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (SetFileToCurrentTime (hOF)) SendDlgItemMessage (p-> hDlg, IDC_LIST1, LB_ADDSTRING, NULL, (LPARAM) TEXT ("Done!")); CloseHandle (hOF); But still does not change the date. - Vadim Yakushkin

0