Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Lange Pfade in Kurze (Tilded) "DOS" Pfade umwandeln? (https://www.delphipraxis.net/58998-lange-pfade-kurze-tilded-dos-pfade-umwandeln.html)

supermuckl 15. Dez 2005 16:11


Lange Pfade in Kurze (Tilded) "DOS" Pfade umwandel
 
Hallo.
Ich such mir grad einen ab, aber finde nichts an Windows APIs,
die mir einen langen Pfad (mit leerzeichen und so weiter) in einen gekürzten Pfad ( der mit ~ abgeschlossen ist z.b.) umwandelt

also diese "DOS" Pfad/Dateinamen.

gibt es da eine API die mir das umwandelt ?

Ferber 15. Dez 2005 16:26

Re: Lange Pfade in Kurze (Tilded) "DOS" Pfade umwa
 
Hi !
Falls Office installiert ist findest Du unter

"C:\Programme\Microsoft Office\Office\Samples\SAMPLES.XLS"

ein brauchbares Beispiel in VB.

Delphi-Quellcode:
Private Declare Function GetShortPathName Lib "KERNEL32.DLL" Alias "GetShortPathNameA" _
                                                            (ByVal lpctstrLongName As String, _
                                                            ByVal lptstrShortName As String, _
                                                            ByVal bufLen As Long) As Long

Sub Get_Short_Name()
    Dim LongStr As String, ShortStr As String
    Dim lStrLen As Long, lRet As Long
   
    'LongStr ist irgend ein langer Dateiname.
    'ShortStr ist der hierzu definierte Name, der der
    '        DOS-Namenskonvention (8+3 Zeichen)genügt.
   
    LongStr = ThisWorkbook.FullName
    lRet = GetShortPathName(LongStr, ShortStr, lStrLen)
    'Mit dem folgenden Befehl legen wir einen Puffer an,
    'der genauso lang ist wie die zurückgegebene Zeichenkette.
    'Damit ersparen wir uns, die Zeichenkette links abschneiden
    'zu müssen.
    ShortStr = String(lRet, " ")
    lRet = GetShortPathName(LongStr, ShortStr, lRet)
    MsgBox LongStr & "  entspricht dem Kurzen Namen  " & ShortStr
End Sub

supermuckl 15. Dez 2005 16:43

Re: Lange Pfade in Kurze (Tilded) "DOS" Pfade umwa
 
ok vielen dank :)

aus der delphi hilfe:
Delphi-Quellcode:

DWORD GetShortPathName(

    LPCTSTR lpszLongPath,   // points to a null-terminated path string
    LPTSTR lpszShortPath,   // points to a buffer to receive the null-terminated short form of the path
    DWORD cchBuffer    // specifies the size of the buffer pointed to by lpszShortPath
   );


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:02 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz