Click here to Skip to main content
15,919,613 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WM_SHUTDOWN notification Win32 dll Pin
geo_m23-Nov-04 1:37
geo_m23-Nov-04 1:37 
GeneralRe: WM_SHUTDOWN notification Win32 dll Pin
AssemblySoft23-Nov-04 10:43
AssemblySoft23-Nov-04 10:43 
GeneralRe: WM_SHUTDOWN notification Win32 dll Pin
BaldwinMartin23-Nov-04 10:21
BaldwinMartin23-Nov-04 10:21 
GeneralRe: WM_SHUTDOWN notification Win32 dll Pin
AssemblySoft23-Nov-04 10:40
AssemblySoft23-Nov-04 10:40 
GeneralRe: WM_SHUTDOWN notification Win32 dll Pin
BaldwinMartin23-Nov-04 10:46
BaldwinMartin23-Nov-04 10:46 
GeneralThread termination problem. Pin
ledallam22-Nov-04 21:38
ledallam22-Nov-04 21:38 
GeneralRe: Thread termination problem. Pin
Joaquín M López Muñoz22-Nov-04 22:35
Joaquín M López Muñoz22-Nov-04 22:35 
GeneralRe: Thread termination problem. Pin
ledallam22-Nov-04 22:47
ledallam22-Nov-04 22:47 
Hi Joaquín

Thanks for your quick response. I am unable to use the overlapped mode. I mean I am not getting the correct usage syntax.

I simply used stop event as shown below.
UINT CheckFileUpdates(LPVOID lp)
{
//Get the document pointer
CLogViewerAppView* pView = (CLogViewerAppView*)lp;
CLogViewerAppDoc* pDoc = pView->GetDocument();

CFileException err;
CFileStatus st;
CFile::GetStatus(pView->m_LogFilePath,st);
LONG l1,l2;

CFile file;
if( !file.Open(pView->m_LogFilePath, CFile::modeRead|CFile::shareDenyNone, &err ) )
{
TCHAR szCause[255];
err.GetErrorMessage(szCause, 255);
AfxMessageBox(szCause);
return 0;
}
l1 = (LONG)file.GetLength();
file.Close();
CFile file1;
LONG size_1 = (LONG)st.m_size;
int len = pView->m_LogFilePath.GetLength()-pView->m_LogFileName.GetLength()-1;
CString dir = pView->m_LogFilePath.Left(len);
HANDLE hDir = CreateFile( dir, // pointer to the file name
FILE_LIST_DIRECTORY, // access (read/write) mode
FILE_SHARE_READ|FILE_SHARE_WRITE, // share mode
NULL, // security descriptor
OPEN_EXISTING, // how to create
FILE_FLAG_BACKUP_SEMANTICS, // file attributes
NULL // file with attributes to copy
);

FILE_NOTIFY_INFORMATION Buffer[1024];
DWORD BytesReturned;

while( ReadDirectoryChangesW(
hDir, // handle to directory
&Buffer, // read results buffer
sizeof(Buffer), // length of buffer
TRUE, // monitoring option
FILE_NOTIFY_CHANGE_SIZE, // filter conditions
&BytesReturned, // bytes returned
NULL, // overlapped buffer
NULL// completion routine
))
{
if ( WaitForSingleObject(pView->m_StopEvent, INFINITE) == WAIT_OBJECT_0 )
{
OutputDebugString(_T("\n KIIGSRETG \n"));
return 0; //end the thraed

}

CString fileName(Buffer[0].FileName);
fileName = fileName.Left(Buffer[0].FileNameLength / 2);

if(fileName.CompareNoCase(pView->m_LogFileName) == 0)
{
//Do the work
}
}

return 0;
}

But the m_StopEvent event is not caught beacuse the control is stuck at while( ReadDirectoryChangesW) I mean it not going inside the while loop unless ReadDirectoryChangesW returns true. Hence WaitForSingleObject is not checked at all.. Hope you got my point.

Can you please let me know how to write this using OVERLAPPED structure. I never did this before. I am really stuck at this point..unable to proceed further..this is very important for my assignment.


Thanks
Madhavi
QuestionReBar - how to set button state on it? Pin
Darked developer22-Nov-04 20:57
Darked developer22-Nov-04 20:57 
AnswerRe: ReBar - how to set button state on it? Pin
Darked developer22-Nov-04 21:02
Darked developer22-Nov-04 21:02 
GeneralRe: ReBar - how to set button state on it? Pin
pc_dev22-Nov-04 21:13
pc_dev22-Nov-04 21:13 
Generalmodeless dialog Pin
pc_dev22-Nov-04 20:04
pc_dev22-Nov-04 20:04 
GeneralRe: modeless dialog Pin
BaldwinMartin23-Nov-04 10:22
BaldwinMartin23-Nov-04 10:22 
GeneralRe: modeless dialog Pin
pc_dev23-Nov-04 18:21
pc_dev23-Nov-04 18:21 
GeneralTimers and Threads Pin
asv22-Nov-04 19:31
asv22-Nov-04 19:31 
GeneralRe: Timers and Threads Pin
shiraztk22-Nov-04 20:58
shiraztk22-Nov-04 20:58 
GeneralRe: Timers and Threads Pin
David Crow23-Nov-04 3:09
David Crow23-Nov-04 3:09 
GeneralCFileDialog i want select only directories Pin
tiziacaia22-Nov-04 19:29
tiziacaia22-Nov-04 19:29 
GeneralRe: CFileDialog i want select only directories Pin
Michael Dunn22-Nov-04 19:43
sitebuilderMichael Dunn22-Nov-04 19:43 
GeneralRe: CFileDialog i want select only directories Pin
BlackDice23-Nov-04 2:44
BlackDice23-Nov-04 2:44 
GeneralAdding unicode support Pin
Shiva Prasad22-Nov-04 18:34
Shiva Prasad22-Nov-04 18:34 
Generalmfc mysteries Pin
the_augy22-Nov-04 16:47
the_augy22-Nov-04 16:47 
GeneralRe: mfc mysteries Pin
shiraztk22-Nov-04 18:01
shiraztk22-Nov-04 18:01 
GeneralRe: mfc mysteries Pin
the_augy26-Nov-04 19:45
the_augy26-Nov-04 19:45 
GeneralDynamically change menu in main frame Pin
Marcus Spitzmiller22-Nov-04 16:17
Marcus Spitzmiller22-Nov-04 16:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.