Print Page | Close Window

CXTShellTree and UNC Path

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=14794
Printed Date: 28 April 2024 at 9:12am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTShellTree and UNC Path
Posted By: AliRafiee
Subject: CXTShellTree and UNC Path
Date Posted: 22 July 2009 at 11:11am
Did you know that the CXTShellTree control's PopulateTree method doesn't work with UNC paths?
 
The problem is in PathFindNextComponent or XTFuncPathFindNextComponent depending on which version of the library you are using.
 
Anyway, that method will return an invalid path if a UNC path is passed to it
 
in the PathFindNextComponent the if statement should be
 
CString CXTShellTreeBase::PathFindNextComponent(const CString& pszPath)
{
  // Find the path delimiter
   int nIndex = pszPath.Find(_T('\\'));
 
   //if one wasn't found, or the first char is the \
   if (nIndex <= 0)
      return _T("");
 
   return pszPath.Mid(nIndex + 1);
}

and XTFuncPathFindNextComponent should be:

_XT_EXT_CLASS LPTSTR AFXAPI XTFuncPathFindNextComponent(LPTSTR pszPath)
{
  // We will return static memory
   static TCHAR tNextComponent[MAX_PATH + 1];
 
   // Make sure we were given a valid path
   if ( pszPath == NULL || _tcslen( pszPath ) == 0 ) {
      return NULL;
   }
 
   // Find the path delimiter
   TCHAR *cp = _tcschr( pszPath, _T('\\') );
 
   //if one wasn't found, or the first char is the \
   if ( cp == NULL || cp == pszPath) {
      // If we didn't find it, return an empty string
      tNextComponent[0] = 0;
      return tNextComponent;
   }
 
   // OK, we have the delimiter. Copy the rest of
   // the path to our internal buffer and return it
   STRCPY_S( tNextComponent, MAX_PATH , cp + 1 );
   return tNextComponent;
}

 




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net