Declare Function GetFullPathName Lib "kernel32.dll" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long
GetFullPathName appends a specified filename to the name of the current directory. For example, if you specify the file "hello.txt" and the current directory is "C:\My Documents\Junk", the resulting filename would be "C:\My Documents\Junk\hello.txt". This string is put into the string passed as lpBuffer. The function returns 0 if an error occured, or the length of the final string if successful.
Example:
' Set current directory to C:\Windows\Media
ChDir "\Windows\Media"
' Append the filename ding.wav
Dim buffer As String * 255
x = GetFullPathName("ding.wav", 255, buffer, "")
Debug.Print Left(buffer, x) ' should be "C:\Windows\Media\ding.wav"
Related Call: GetShortPathName
Category: Files
Back to the index.