Access-o-Mania

Access-Forum (Deutsch/German) => Access Programmierung => Thema gestartet von: Ozziiee am September 17, 2013, 11:05:59

Titel: Shortpathname... Dos Name ..
Beitrag von: Ozziiee am September 17, 2013, 11:05:59
Mit der 32 Bit  Engine .. hatte ich die Möglichkeit ..Shortpathname und Longpathname zu generieren.. weiß jemand wie ich das Mit Access 2010 64 Bit Versionen wieder zum laufen bringe ?


Siehe Beispiel
Const MAXPATH                   As Long = 260

Type FILETIME
            dwLowDateTime       As Long
            dwHighDateTime      As Long
End Type

Type WIN32_FIND_DATA
            dwFileAttributes    As Long
            ftCreationTime      As FILETIME
            ftLastAccessTime    As FILETIME
            ftLastWriteTime     As FILETIME
            nFileSizeHigh       As Long
            nFileSizeLow        As Long
            dwReserved0         As Long
            dwReserved1         As Long
            cFileName           As String * MAXPATH
            cAlternate          As String * 14
End Type

Declare Function FindFirstFile Lib "kernel32" Alias _
                "FindFirstFileA" _
                (ByVal lpFileName As String, _
                 lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function FindClose Lib "kernel32" _
                (ByVal hFindFile As Long) As Long
Declare Function GetShortPathName Lib "kernel32" Alias _
                "GetShortPathNameA" _
                (ByVal lpszLongPath As String, _
                 ByVal lpszShortPath As String, _
                 ByVal cchBuffer As Long) As Long
Titel: Re: Shortpathname... Dos Name ..
Beitrag von: DF6GL am September 17, 2013, 11:42:53
Declare PtrSafe Function ...
Titel: Re: Shortpathname... Dos Name ..
Beitrag von: Ozziiee am September 17, 2013, 12:29:16
Erst mal danke .. für den Tip .. hab aber noch ein Problem bei der Umsetzung ..

hab mal das Bespiel hier ausgeführt ..

Option Compare Database
Const MAXPATH                   As Long = 260

Type FILETIME
            dwLowDateTime       As Long
            dwHighDateTime      As Long
End Type

Type WIN32_FIND_DATA
            dwFileAttributes    As Long
            ftCreationTime      As FILETIME
            ftLastAccessTime    As FILETIME
            ftLastWriteTime     As FILETIME
            nFileSizeHigh       As Long
            nFileSizeLow        As Long
            dwReserved0         As Long
            dwReserved1         As Long
            cFileName           As String * MAXPATH
            cAlternate          As String * 14
End Type

Declare PtrSafe Function Getshortpathname Lib "kernel32" Alias _
                "GetShortPathNameA" _
                (ByVal lpszLongPath As String, _
                 ByVal lpszShortPath As String, _
                 ByVal cchBuffer As Long) As Long

Function GetShortPath(ByVal sLongPath As String) As String
'// -----------------------------------------------------------------
'// Methode:   | Ermittelt den 8.3 (DOS)-Pfad
'// -----------------------------------------------------------------
'// Parameter: | sLongPath = gültiger Datei- oder Ordnerpfad
'// -----------------------------------------------------------------
'// Rückgabe:  | 8.3 (DOS)-Pfad
'// -----------------------------------------------------------------
    Dim sShortPath  As String
    sShortPath = VBA.String(260, 0)
    If Getshortpathname(sLongPath, sShortPath, Len(sShortPath)) Then
        GetShortPath = _
        VBA.Left(sShortPath, VBA.InStr(sShortPath, vbNullChar) - 1)
    End If

End Function

Sub Beispiel()

    Dim sLongPath   As String
    Dim sShortPath  As String

    sLongPath = "C:\Programme\Microsoft Office\Office10\WINWORD.EXE"
    sShortPath = GetShortPath(sLongPath)
    MsgBox "Der kurze Pfad lautet: " & sShortPath
     
End Sub


bekomme aber keinen Wert zurück, vielleicht kannst ju ja mal rüberschaun .. thxs Ozziie alias db4rn