I have a win32 API application in visual c++ in which I want to save recently viewed or opened folder to a log file. I have a code which stores the current window open to a log file. The code for current window opened is as following. Can this code be manipulated to create log file for recently viewed folder.
static TCHAR wndText[100];
TCHAR tempWndText[100];
TCHAR timestamp[255];
DWORD written;
time_t t=time(0);
ctime_s(timestamp,sizeof(timestamp),&t);
SetFilePointer(_Wfile,0,NULL,FILE_END);
TCHAR buf[255];
wsprintf(buf,"\r\n-->%s\r\n",timestamp);
WriteFile(_Wfile,buf,(DWORD)lstrlen(buf)*sizeof(TCHAR),&written,NULL);
while(1)
{
Sleep(5);
flush();
hWndCurWnd=GetForegroundWindow();
GetWindowText(hWndCurWnd,tempWndText,100);
if(_Wfile==INVALID_HANDLE_VALUE)
{
return;
}
if(lstrcmp(tempWndText,wndText)!=0)
{
lstrcpyn(wndText,tempWndText,255);
wsprintf(buf,"\r[%s]\r\n",wndText);
WriteFile(_Wfile,buf,(DWORD)lstrlen(buf)*sizeof(TCHAR),&written,NULL);
}
}