;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfPathStripToRoot (strPath) ; JustRoot If strPath == "" Then Return "" intMAX_PATH = 260 hdlBB = BinaryAlloc (intMAX_PATH) BinaryPokeStr (hdlBB, 0, strPath) intResult = DllCall ("SHLWAPI.DLL", long : "PathStripToRootA", lpbinary : hdlBB) strPath = "" If intResult Then strPath = BinaryPeekStr (hdlBB, 0, intMAX_PATH) hdlBB = BinaryFree (hdlBB) Return strPath ;.......................................................................................................................................... ; Removes all path parts of the strPath except for the root information. ; Returns empty string if strPath is relative path. ; Example: udfStripToRoot ("C:\windows\file.exe") ==> "C:\" ; Example: udfStripToRoot ("\\FS\SHARE\folder\file.exe") ==> "\\FS\SHARE" ; ; Detlev Dalitz.20010807 ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. strString1 = "\\SERVER\SHARE\FOLDER\FOLDER\FILE1.EXT" strString2 = "A:\FOLDER\FOLDER\FILE2.EXT" strString3 = "\FOLDER\FOLDER\FILE3.EXT" strString4 = "\FILE4.EXT" strString5 = "A:..\FILE5.EXT" strString6 = "..\FILE6.EXT" strString7 = "FILE7.EXT" strPathRoot1 = udfPathStripToRoot (strString1) ; "\\SERVER\SHARE" strPathRoot2 = udfPathStripToRoot (strString2) ; "A:\" strPathRoot3 = udfPathStripToRoot (strString3) ; "\" strPathRoot4 = udfPathStripToRoot (strString4) ; "\" strPathRoot5 = udfPathStripToRoot (strString5) ; "" strPathRoot6 = udfPathStripToRoot (strString6) ; "" strPathRoot7 = udfPathStripToRoot (strString7) ; "" strFilePath1 = StrSub (FilePath (strString1), StrLen (strPathRoot1) + 1, -1) ; "\FOLDER\FOLDER\" strFilePath2 = StrSub (FilePath (strString2), StrLen (strPathRoot2) + 1, -1) ; "FOLDER\FOLDER\" strFilePath3 = StrSub (FilePath (strString3), StrLen (strPathRoot3) + 1, -1) ; "FOLDER\FOLDER\" strFilePath4 = StrSub (FilePath (strString4), StrLen (strPathRoot4) + 1, -1) ; "" strFilePath5 = StrSub (FilePath (strString5), StrLen (strPathRoot5) + 1, -1) ; "A:..\" strFilePath6 = StrSub (FilePath (strString6), StrLen (strPathRoot6) + 1, -1) ; "..\" strFilePath7 = StrSub (FilePath (strString7), StrLen (strPathRoot7) + 1, -1) ; "" strFileBaseName1 = FileBaseName (strString1) ; "FILE1.EXT" strFileBaseName2 = FileBaseName (strString2) ; "FILE2.EXT" strFileBaseName3 = FileBaseName (strString3) ; "FILE3.EXT" strFileBaseName4 = FileBaseName (strString4) ; "FILE4.EXT" strFileBaseName5 = FileBaseName (strString5) ; "FILE5.EXT" strFileBaseName6 = FileBaseName (strString6) ; "FILE6.EXT" strFileBaseName7 = FileBaseName (strString7) ; "FILE7.EXT" Exit