Here's the OK button handler from a dialog app I wrote a while ago that updates the created/accessed/modified times for a given file (error checking removed):
Code:case ID_OK: { // Get the name of the file... TCHAR szFile[MAX_PATH] = {0}; GetWindowText(GetDlgItem(hwnd, IDC_FILENAME), szFile, sizeof(szFile) / sizeof(TCHAR)); // Get each of the date/time values... SYSTEMTIME st = {0}; st.wMonth = GetDlgItemInt(hwnd, IDC_MONTH, NULL, FALSE); st.wDay = GetDlgItemInt(hwnd, IDC_DAY, NULL, FALSE); st.wYear = GetDlgItemInt(hwnd, IDC_YEAR, NULL, FALSE); st.wHour = GetDlgItemInt(hwnd, IDC_HOUR, NULL, FALSE); st.wMinute = GetDlgItemInt(hwnd, IDC_MIN, NULL, FALSE); // Convert the SYSTEMTIME to a FILETIME... FILETIME ft = {0}; SystemTimeToFileTime(&st, &ft); // Write the new filetime... HANDLE hFile = CreateFile(szFile, FILE_WRITE_ATTRIBUTES, NULL, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); SetFileTime(hFile, &ft, &ft, &ft); CloseHandle(hFile); return FALSE; }




Reply With Quote