Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with the PathFindOnPath Call in VB 1

Status
Not open for further replies.

VBRookie

Programmer
May 29, 2001
331
US
Hi,

VB Rookie here again. I'm wondering if anybody knows how to use the PathFindOnPath API Call in Visual Basic. It's supposed to take a file name and search the hard-drive for it, returning the fully-qualified pathname if the file is found.

At least that's what the documentation says, but I am not able to retrieve the path of the file which is what I need. This is the code that I'm using, I'm putting the first parameter (filename) in a message box after the function is called to see if the path is coming back but it is not:

FileName = "textXls.xls"
Call PathFindOnPath(FileName, vbNullString)

I have the function declared on my form as :

Private Declare Function PathFindOnPath Lib "shlwapi.dll" Alias "PathFindOnPathA" (ByVal pszPath As String, ByVal ppszOtherDirs As String) As Boolean

Any help is appreciated.

Thanks,
- VB Rookie
 
It only returns True or False. Also with no second parameter, it only searches certain stadard directories. This function does not return a path.
Drom MSDN
PathFindOnPath
Searches for a file.

BOOL PathFindOnPath(
LPTSTR pszFile,
LPCTSTR * ppszOtherDirs
);

Parameters
pszFile
File name for which to search. If the search is successful, this parameter is used to return the fully qualified path name.
ppszOtherDirs
Optional null-terminated array of directories to be searched first.
Return Values
Returns TRUE if successful, or FALSE otherwise.

Remarks
PathFindOnPath searches for the file specified by pszFile. If no directories are specified in ppszOtherDirs, it attempts to find the file by searching standard directories such as System32 and the directories specified in the PATH environment variable. To expedite the process or enable PathFindOnPath to search a wider range of directories, use the ppszOtherDirs parameter to specify one or more directories to be searched first. If more than one file has the name specified by pszFile, PathFindOnPath returns the first instance it finds.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top