<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : CXTDirWatcher Crash</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Toolkit Pro : CXTDirWatcher Crash]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Sat, 13 Jun 2026 16:41:43 +0000</pubDate>
  <lastBuildDate>Tue, 14 Nov 2006 13:37:50 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=3685</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[CXTDirWatcher Crash : Yes, it was fixed in some old...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3685&amp;PID=17302&amp;title=cxtdirwatcher-crash#17302</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 3685<br /><strong>Posted:</strong> 14 November 2006 at 1:37pm<br /><br />Yes, it was fixed in some old version. ]]>
   </description>
   <pubDate>Tue, 14 Nov 2006 13:37:50 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3685&amp;PID=17302&amp;title=cxtdirwatcher-crash#17302</guid>
  </item> 
  <item>
   <title><![CDATA[CXTDirWatcher Crash : I believe they fixed this problem...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3685&amp;PID=17301&amp;title=cxtdirwatcher-crash#17301</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=504">AliRafiee</a><br /><strong>Subject:</strong> 3685<br /><strong>Posted:</strong> 14 November 2006 at 11:50am<br /><br />I believe they fixed this problem in 9.7.&nbsp; What they did to fix the problem is that they added another event to the event list that the thread listens for, this event is a quit event. And then they set this event in the destructor of the controls that use this threads, so that the thread actually ends when the control is destroyed.<DIV>&nbsp;</DIV><DIV>Ali</DIV>]]>
   </description>
   <pubDate>Tue, 14 Nov 2006 11:50:52 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3685&amp;PID=17301&amp;title=cxtdirwatcher-crash#17301</guid>
  </item> 
  <item>
   <title><![CDATA[CXTDirWatcher Crash : No answer to this question yet?I...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3685&amp;PID=17298&amp;title=cxtdirwatcher-crash#17298</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2063">RedDragon</a><br /><strong>Subject:</strong> 3685<br /><strong>Posted:</strong> 14 November 2006 at 11:40am<br /><br />No answer to this question yet?<br><br>I have a problem with object as well... the CXTShellListCtrlEx object sends notifications in RefreshFolder() even though the window is destroyed, and the DirWatcher is protected so there is no way to stop this behavior...<br><br>Well, the solution I'm using now is to override this object which gives me access to the StopNotifications function. But I'd rather like this to be within CodeJock, if possible?<br><br>]]>
   </description>
   <pubDate>Tue, 14 Nov 2006 11:40:16 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3685&amp;PID=17298&amp;title=cxtdirwatcher-crash#17298</guid>
  </item> 
  <item>
   <title><![CDATA[CXTDirWatcher Crash : Hi, I have a CXTShellListCtrl...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3685&amp;PID=11093&amp;title=cxtdirwatcher-crash#11093</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=504">AliRafiee</a><br /><strong>Subject:</strong> 3685<br /><strong>Posted:</strong> 21 February 2006 at 11:51am<br /><br /><P>Hi,</P><P>I have a <FONT size=2>CXTShellListCtrl in a dialog box.&nbsp; When I close the dialog box and then navigate using the Windows Explorer to the directory that the <FONT size=2>CXTShellListCtrl was displaying and delete a file, or add a file my program will crash.&nbsp;<IMG src="http://forum.codejock.com/smileys/smiley11.gif" border="0"> </FONT></FONT></P><P><FONT size=2><FONT size=2>It crashes in <FONT size=2><FONT size=2>CXTDirWatcher</FONT>, there is a WaitForMultipleObject(...,INIFINT) in the InitInstance, since the dialog box is closed thread object is actually deleted, but it is still running, when the event hits, the thread crashes.</FONT></FONT></FONT></P><P><FONT size=2><FONT size=2><FONT size=2>If I remember correctly I sent you guys a fix for this a year or so ago?</FONT></FONT></FONT></P><P><FONT size=2><FONT size=2><FONT size=2>Do you guys have a fix for this?</FONT></FONT></FONT></P><P><FONT size=2><FONT size=2><FONT size=2>If I remember correctly the fix is to change the thread into a worker thread instead of a gui thread.</FONT></FONT></FONT></P><P><FONT size=2></FONT>&nbsp;</P><P><FONT size=2>// XTDirWatcher.cpp : implementation file<BR>//<BR>// This file is a part of the XTREME TOOLKIT MFC class library.<BR>// ©2004 Codejock Software, All Rights Reserved.<BR>//<BR>// THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE <BR>// RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN <BR>// CONSENT OF CODEJOCK SOFTWARE.<BR>//<BR>// THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED <BR>// IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT.&nbsp; CODEJOCK SOFTWARE GRANTS TO <BR>// YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A <BR>// SINGLE COMPUTER.<BR>//<BR>// CONTACT INFORMATION:<BR>// <A href="mailto:support@codejock.com" target="_blank">support@codejock.com</A><BR>// <A href="http://www.codejock.com" target="_blank">http://www.codejock.com</A><BR>//<BR>//////////////////////////////////////////////////////////// /////////////////</FONT></P><P><FONT size=2>#include "stdafx.h"<BR>#include "XTDefines.h"<BR>#include "XTGlobal.h"<BR>#include "XTDirWatcher.h"</FONT></P><P><FONT size=2>#include &lt;io.h&gt;</FONT></P><P><FONT size=2>#ifdef _DEBUG<BR>#define new DEBUG_NEW<BR>#undef THIS_FILE<BR>static char THIS_FILE&#091;&#093; = __FILE__;<BR>#endif</FONT></P><P><FONT size=2>UINT DirWatcherThread(void *pParam);<BR>//////////////////////////////////////////////////////////// /////////////////<BR>// CXTDirWatcher</FONT></P><P><FONT size=2>CXTDirWatcher::CXTDirWatcher()<BR>: m_Exit(FALSE)<BR>, m_pThread(NULL)<BR>{<BR>//&nbsp;m_bAutoDelete = FALSE;<BR>}</FONT></P><P><FONT size=2>CXTDirWatcher::~CXTDirWatcher()<BR>{<BR>&nbsp;&nbsp; m_Exit = TRUE;<BR>}</FONT></P><P><FONT size=2>void CXTDirWatcher::StartMonitoring()<BR>{<BR>&nbsp;&nbsp; m_pThread = AfxBeginThread(DirWatcherThread,this);<BR>}</FONT></P><P><FONT size=2>void CXTDirWatcher::SuspendThread()<BR>{<BR>&nbsp;&nbsp; ASSERT(m_pThread);<BR>&nbsp;&nbsp; m_pThread-&gt;SuspendThread();<BR>}</FONT></P><P><FONT size=2>void CXTDirWatcher::ResumeThread()<BR>{<BR>&nbsp;&nbsp; ASSERT(m_pThread);<BR>&nbsp;&nbsp; m_pThread-&gt;ResumeThread();<BR>}</FONT></P><P><FONT size=2>BOOL CXTDirWatcher::IsPathValid(LPCTSTR lpszFolderPath)<BR>{<BR>&nbsp;if (_tcslen(lpszFolderPath) == 0)<BR>&nbsp;&nbsp;return FALSE;</FONT></P><P><FONT size=2>&nbsp;if (_taccess(lpszFolderPath, 0) == -1)<BR>&nbsp;&nbsp;return FALSE;</FONT></P><P><FONT size=2>&nbsp;return TRUE;<BR>}</FONT></P><P><FONT size=2>BOOL CXTDirWatcher::SetFolderPath(CWnd* pMainWnd, LPCTSTR lpszFolderPath)<BR>{<BR>&nbsp;if (IsPathValid(lpszFolderPath))<BR>&nbsp;{<BR>&nbsp;&nbsp;if (GetFolderData(lpszFolderPath, m_tvid))<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;m_pMainWnd = pMainWnd;<BR>&nbsp;&nbsp;&nbsp;m_strFolderPath = lpszFolderPath;</FONT></P><P><FONT size=2>&nbsp;&nbsp;&nbsp;return TRUE;<BR>&nbsp;&nbsp;}<BR>&nbsp;}</FONT></P><P><FONT size=2>&nbsp;return FALSE;<BR>}</FONT></P><P><FONT size=2>BOOL CXTDirWatcher::SetFolderData(CWnd* pMainWnd, XT_TVITEMDATA* lpTVID)<BR>{<BR>&nbsp;if (!lpTVID)<BR>&nbsp;&nbsp;return FALSE;</FONT></P><P><FONT size=2>&nbsp;TCHAR szFolderPath&#091;_MAX_PATH&#093;;<BR>&nbsp;if (::SHGetPathFromIDList(lpTVID-&gt;lpifq, szFolderPath))<BR>&nbsp;{<BR>&nbsp;&nbsp;return SetFolderPath(pMainWnd, szFolderPath);<BR>&nbsp;}</FONT></P><P><FONT size=2>&nbsp;return FALSE;<BR>}</FONT></P><P><FONT size=2>BOOL CXTDirWatcher::GetFolderData(LPCTSTR lpszFolderPath, XT_TVITEMDATA&amp; lpTVID)<BR>{<BR>&nbsp;LPITEMIDLIST&nbsp; pidl;<BR>&nbsp;LPSHELLFOLDER pDesktopFolder;<BR>&nbsp;OLECHAR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; szOleChar&#091;MAX_PATH&#093;; <BR>&nbsp;ULONG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chEaten; <BR>&nbsp;ULONG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dwAttributes; </FONT></P><P><FONT size=2>&nbsp;if (!IsPathValid(lpszFolderPath))<BR>&nbsp;&nbsp;return FALSE;<BR>&nbsp;<BR>&nbsp;// Get a pointer to the Desktop's IShellFolder interface. <BR>&nbsp;if ( SUCCEEDED( ::SHGetDesktopFolder( &amp;pDesktopFolder ) ) ) <BR>&nbsp;{ <BR>&nbsp;&nbsp;// IShellFolder::ParseDisplayName requires the file name be in <BR>&nbsp;&nbsp;// Unicode. </FONT></P><P><FONT size=2>#if !defined( _UNICODE )<BR>&nbsp;&nbsp;::MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, lpszFolderPath, -1, <BR>&nbsp;&nbsp;&nbsp;szOleChar, MAX_PATH );<BR>#else<BR>&nbsp;&nbsp;::_tcscpy( szOleChar, lpszFolderPath );<BR>#endif</FONT></P><P><FONT size=2>&nbsp;&nbsp;// Convert the path to an ITEMIDLIST. <BR>&nbsp;&nbsp;if ( SUCCEEDED( pDesktopFolder-&gt;ParseDisplayName( NULL,NULL,szOleChar,<BR>&nbsp;&nbsp;&nbsp;&amp;chEaten,&amp;pidl,&amp;dwAttributes) ) )<BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;IShellFolder *psfMyFolder; <BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;lpTVID.lpi = lpTVID.lpifq = pidl; <BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;pDesktopFolder-&gt;BindToObject( lpTVID.lpifq,NULL, <BR>&nbsp;&nbsp;&nbsp;&nbsp;IID_IShellFolder,(LPVOID*)&amp;psfMy Folder );</FONT></P><P><FONT size=2>&nbsp;&nbsp;&nbsp;lpTVID.lpsfParent = psfMyFolder; <BR>&nbsp;&nbsp;&nbsp;pDesktopFolder-&gt;Release();</FONT></P><P><FONT size=2>&nbsp;&nbsp;&nbsp;return TRUE;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;pDesktopFolder-&gt;Release();<BR>&nbsp;}</FONT></P><P><FONT size=2>&nbsp;return FALSE;<BR>} </FONT></P><P><FONT size=2>void CXTDirWatcher::RefreshFolder()<BR>{<BR>&nbsp;m_pMainWnd-&gt;SendMessage( XTWM_SHELL_NOTIFY,<BR>&nbsp;&nbsp;SHN_XT_REFRESHFOLDER, (LPARAM)&amp;m_tvid );<BR>}</FONT></P><P><FONT size=2>void CXTDirWatcher::RefreshTree()<BR>{<BR>&nbsp;m_pMainWnd-&gt;SendMessage( XTWM_SHELL_NOTIFY,<BR>&nbsp;&nbsp;SHN_XT_REFRESHTREE, (LPARAM)&amp;m_tvid );<BR>}</FONT></P><FONT size=2><P><BR>UINT DirWatcherThread(void *pParam)<BR>{<BR>&nbsp;&nbsp; CXTDirWatcher *pWatcher = reinterpret_cast&lt;CXTDirWatcher *&gt;(pParam);</P><P>&nbsp;HANDLE&nbsp;&nbsp;&nbsp;m_dwChangeHandles&#091;2&#093;;&nbsp;// Change event handles.</P><P>&nbsp;&nbsp; m_dwChangeHandles&#091;0&#093; = INVALID_HANDLE_VALUE;<BR>&nbsp;m_dwChangeHandles&#091;1&#093; = INVALID_HANDLE_VALUE;</P><P>&nbsp;&nbsp; if (pWatcher-&gt;IsPathValid(pWatcher-&gt;GetFolderPath()))<BR>&nbsp;{<BR>&nbsp;&nbsp;// Watch the directory for file creation and <BR>&nbsp;&nbsp;// deletion. <BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;m_dwChangeHandles&#091;0&#093; = ::FindFirstChangeNotification( <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  pWatcher-&gt;GetFolderPath(),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp; nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // directory to watch <BR>&nbsp;&nbsp;&nbsp;FALSE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // do not watch the subtree <BR>&nbsp;&nbsp;&nbsp;FILE_NOTIFY_CHANGE_FILE_NAME); // watch file name changes <BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;if (m_dwChangeHandles&#091;0&#093; == INVALID_HANDLE_VALUE) <BR>&nbsp;&nbsp;&nbsp;return 0; <BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;// Watch the tree for directory creation and <BR>&nbsp;&nbsp;// deletion. <BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;m_dwChangeHandles&#091;1&#093; = ::FindFirstChangeNotification( <BR>&nbsp;&nbsp;&nbsp;  pWatcher-&gt;GetFolderPath(),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp; nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // directory to watch <BR> &nbsp;&nbsp;&nbsp;TRUE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;  nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp; nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // watch the subtree <BR>&nbsp;&nbsp;&nbsp;FILE_NOTIFY_CHANGE_DIR_NAME);&nbsp; // watch dir. name changes <BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;if (m_dwChangeHandles&#091;1&#093; == INVALID_HANDLE_VALUE) <BR>&nbsp;&nbsp;&nbsp;return 0;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;// Change notification is set. Now wait on both notification <BR>&nbsp;&nbsp;// handles and refresh accordingly. </P><P>&nbsp;&nbsp;while (!pWatcher-&gt;MustExit()) <BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;// Wait for notification.<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;DWORD m_dwWaitStatus = ::WaitForMultipleObjects(_countof(m_dwChangeHandles),<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_dwChangeHandles, FALSE, 10);</P><P>&nbsp;&nbsp;&nbsp;switch (m_dwWaitStatus)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;case WAIT_OBJECT_0:<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;// A file was created or deleted in C:\WINDOWS. <BR>&nbsp;&nbsp;&nbsp;&nbsp;// Refresh this directory and restart the <BR>&nbsp;&nbsp;&nbsp;&nbsp;// change notification. RefreshDirectory is an <BR>&nbsp;&nbsp;&nbsp;&nbsp;// application-defined function. <BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;pWatcher-&gt;RefreshFolder();</P><P>&nbsp;&nbsp;&nbsp;&nbsp;if (!::FindNextChangeNotification(m_dwChangeHandles&#091;0&#093;))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;</P><P>&nbsp;&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;case WAIT_OBJECT_0 + 1: <BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;// A directory was created or deleted in C:\. <BR>&nbsp;&nbsp;&nbsp;&nbsp;// Refresh the directory tree and restart the <BR>&nbsp;&nbsp;&nbsp;&nbsp;// change notification. RefreshTree is an <BR>&nbsp;&nbsp;&nbsp;&nbsp;// application-defined function. <BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;pWatcher-&gt;RefreshTree();</P><P>&nbsp;&nbsp;&nbsp;&nbsp;if (!FindNextChangeNotification(m_dwChangeHandles&#091;1&#093;))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;</P><P>&nbsp;&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>&nbsp;&nbsp; return 0;<BR>}<BR></FONT></P><P><FONT size=2><FONT size=2><FONT size=2>Ali Rafiee</P></FONT></FONT></FONT>]]>
   </description>
   <pubDate>Tue, 21 Feb 2006 11:51:36 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3685&amp;PID=11093&amp;title=cxtdirwatcher-crash#11093</guid>
  </item> 
 </channel>
</rss>