SmileeTiger
Programmer
I am trying to find the time that a particular file has been written to last. The following is the code I used:<br><br>void CNodeLockIDGenDlg::OnButton1() <br>{<br> <br> OFSTRUCT ofs;<br>HFILE hFile;<br>if(hFile=OpenFile("c:\\temp.cor", (LPOFSTRUCT) &ofs, OF_READ) == HFILE_ERROR) //temp.cor is just a file I created today<br>AfxMessageBox("Could not open file!!"<br><br><br>FILETIME lpLastWriteTime;<br>//FILETIME lpCreateTime;<br>//FILETIME lpAccessTime;<br><br><br>int a=GetFileTime(<br> (HANDLE)hFile, // handle to file<br> (LPFILETIME) NULL, // creation time<br> (LPFILETIME) NULL, // last access time<br> &lpLastWriteTime // last write time<br> );<br>SYSTEMTIME lpSysTime;<br>if(!FileTimeToSystemTime(<br> &lpLastWriteTime, // file time to convert<br> &lpSysTime // receives system time<br> ))<br>AfxMessageBox("Something wrong"<br><br>m_Temp=lpSysTime.wYear; //m_temp is a edit box of type DWORD<br>UpdateData(false);<br>CloseHandle((HANDLE) hFile);<br><br>}<br><br>The result I keep getting back is 1618 this happens even if I change the file that hFile is pointing to. Does anyone have any ideas on what I am doing wrong?<br><br><br>Cory<br><br><br><br>