Clarification of SearchPath() Return ValueLast reviewed: September 25, 1995Article ID: Q115826  | 
	
	
 
The information in this article applies to:
 
 SUMMARYThe entry for "SearchPath()" in the "Win32 Programmer's Reference" says that the return value will be one of the following: 
 In order to distinguish the "file not found" condition from another error (out of memory, invalid parameter, and so forth), call SetLastError() with a value of NO_ERROR before calling SearchPath(). 
 MORE INFORMATIONThis behavior is by design. The recommended way to check the return status for SearchPath() is: 
 return value > buffer length buffer too small return value = 0 file not found or another error return value <= buffer length file foundHandle the case where the return value is 0 as follows: 
    TCHAR  szFilename[] = "MyFile.Txt";
   TCHAR  szPathname[MAX_PATH];
   LPTSTR lpszFilename;
   SetLastError( NO_ERROR );
   if( !SearchPath( NULL, szFilename, NULL, MAX_PATH, szPathname,
                    &lpszFilename ) )
   {
      if( GetLastError() == NO_ERROR )
         Display( "File not found." );
      else
         Display( "SearchPath failed!" );
   }
	
	 | 
	
	Additional reference words: 3.10 
 © 1998 Microsoft Corporation. All rights reserved. Terms of Use.  |