|
-
July 22nd, 2005, 10:36 AM
#1
accessing file time structures without MFC?
I wrote a little unix-like "touch" utility to reset file timestamps to the current time... but I used MFC headers to access the structure. I've been looking through the msdn trying to find a way to do this without MFC, so I can put the function into a regular dll, but I haven't found anything yet. Anyone know what classes/methods to use in the winapi or ansi c++ to access/mutate file timestamps?
Sam.
-
July 22nd, 2005, 10:44 AM
#2
Re: accessing file time structures without MFC?
are you talking about those api File Times ?
Cheers
-
July 22nd, 2005, 11:48 AM
#3
Re: accessing file time structures without MFC?
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;
}
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-
July 22nd, 2005, 06:51 PM
#4
Re: accessing file time structures without MFC?
haha... yeah, i found all that stuff in the MSDN after i posted this. disregard this thread...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|