thanks for the usefull code.
i want to ask u if know that ReadDirectoryChangesW with FILE_NOTIFY_CHANGE_FILE_NAME is not giving consistent notification. it sometime misses files.
if u encountered this problem, do u know about a workaround or a another similar method?
But it does't show Network Neighborhood?
it shows only if mapped !
but it is far backward than windows explorer
more work is required .
if anyone have solution (in vc++)
pl. send it to me at firstname.lastname@example.org
I was racking my brain on why I kept getting a compile error 2605 when attempting to us ReadDirectoryChangesW(). Thank for putting this project here.
I am new to this fuction. The NextEntryOffByte is the number of bytes to be skipped to get to the next record. Does that mean you can (somehow) scroll through and get information on more files, if they exist?
This control was great, but I wanted to start in a particular directory and center the scrollbar on that directory. It only required modifying the Init and InitDriveInfo functions to take in a CString, and a path parsing function. This is how I managed to do it. (Note, ... indicates code deleted for brevity)
void CDirTreeCtrl::Init(CString initdir)
//Pass in the initdir to set up a directory
In the InitDriveInfo function I added the following code to the bottom of the function. This will call a function ParsePath (taken from code posted by John McTainsh on this web site)
//Expand the Tree to the Inital Path.
int nLevel = 0;
HTREEITEM hCurrent = hRootItem; //Current item in the list being expanded.
if( initDir.IsEmpty() )
initDir = _T("C:\\"); //if nothing is passed in, default to c:\
while( ParsePath( initDir, nLevel, &sDirName ) )
//Search for the matching tree item and expand
HTREEITEM hItem = GetChildItem( hCurrent );
while( hItem )
if( sDirName.CompareNoCase( GetItemText( hItem ) ) == 0 )
hCurrent = hItem;
Expand( hCurrent, TVE_EXPAND );
EnsureVisible(hCurrent); //centers control onto the current directory
hItem = GetNextSiblingItem( hItem );
//find the passed in path
bool CDirTreeCtrl::ParsePath( CString sPath, int nLevel, CString *const psDirName )
//find first match
int nStart = 0; //Location in sPath to search from
while( nLevel )
nStart = sPath.Find( _T('\\'), nStart );
if( nStart < 0 )
//We now have the start point to find the end.
int nEnd = sPath.Find( _T('\\'), nStart );
if( nEnd < 0 )
*psDirName = sPath.Mid( nStart );
*psDirName = sPath.Mid( nStart, nEnd-nStart);
//if we have a c: psDirName, append a \\ to make it 'c:\'
if ((*psDirName).Right(1) == _T(":"))
*psDirName += "\\";
If have been spoting what you did and it was nearly what I was looking for.
I'm triyng to use a treeview control in Visual Basic and see the directory tree.
Can you convert it to a control or you know the way to do what i want to do with the VB treeview control ???