Sunday, June 13, 2010

UseFull Functions

UseFull VB.NET Functions : GetLongName

#Region " Short Path Name Conversion "
 
    Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" (ByVal lpszShortPath As String, ByVal lpszLongPath As String, ByVal cchBuffer As Integer) As Integer
 
    Public Function GetLongName(ByVal sShortFileName As String) As String
        Dim lRetVal As Long, sShortPathName As String, iLen As Integer
        'Set up buffer area for API function call return
        sShortPathName = Space(255)
        iLen = Len(sShortPathName)
        'Call the function
        lRetVal = GetLongPathName(sShortFileName, sShortPathName, iLen)
        'Strip away unwanted characters.
        Return Left(sShortPathName, lRetVal)
    End Function
#End Region

No comments:

Post a Comment