Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Mar 10, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

SearchFileOnPath - Search a file on system path

Private Declare Function SearchPath Lib "kernel32" Alias "SearchPathA" (ByVal _
    lpPath As String, ByVal lpFileName As String, ByVal lpExtension As String, _
    ByVal nBufferLength As Long, ByVal lpBuffer As String, _
    ByVal lpFilePart As String) As Long

' Search a file on the system
' returns the complete file path+name, or "" if file not found
' If SearchDirs is omitted, then the file is searched
' in the following directories, in this order
'   1. the directory from where the app loaded
'   2. the current directory
'   3. the \Windows\System32 directory (if under WinNT)
'   4. the \Windows\System directory
'   5. the \Windows directory
'   6. the directories listed in the PATH environment variable

Function SearchFileOnPath(ByVal FileName As String, _
    Optional SearchDirs As String) As String
    Dim buffer As String * 260
    Dim length As Long
    Dim sDirs As String
    ' if 2nd argument is omitted, leave sDirs = vbNullString
    If Len(SearchDirs) Then sDirs = SearchDirs
    length = SearchPath(sDirs, FileName, vbNullString, Len(buffer), buffer, _
    SearchFileOnPath = Left$(buffer, length)

End Function
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date