Functions.SplitPath 方法 (__Psz, __Psz, __Psz, __Psz, __Psz) |
注意:此 API 现在已过时。
命名空间: XSharp.RT
[ObsoleteAttribute("'SplitPath()' with PSZ arguments is no longer supported. Please use SplitPath() or _SplitPath() (both with STRING arguments) in stead", FALSE)] FUNCTION SplitPath( pszPathName AS PSZ, pszDrive AS PSZ, pszDir AS PSZ, pszFile AS PSZ, pszExt AS PSZ ) AS VOID
1FUNCTION Start() 2 LOCAL cDrive, cDir, cFile, cExt AS STRING 3 MySplitPath("c:\develop\myprg\hello.prg", ; 4 @cDrive, @cDir, @cFile, @cExt) 5 ? cDrive // C: 6 ? cDir // \DEVELOP\MYPRG 7 ? cFile // HELLO 8 ? cExt // .PRG 9FUNCTION MySplitPath(cPath AS STRING, ; 10 cDrive REF STRING, ; 11 cDir REF STRING, ; 12 cFile REF STRING, ; 13 cExt REF STRING) 14 LOCAL pszPath, pszDrive, pszDir AS PSZ 15 LOCAL pszFile, pszExt AS PSZ 16 LOCAL cb 17 pszPath := MemAlloc(cb := SLen(cPath) + 1) 18 MemCopy(pszPath, PTR(_CAST, cPath), cb) 19 pszDrive := MemAlloc(2+1) 20 pszDir := MemAlloc(255+1) 21 pszFile := MemAlloc(255+1) 22 pszExt := MemAlloc(7+1) 23 SplitPath(cPath, pszDrive, pszDir, ; 24 pszFile, pszExt) 25 cDrive := Psz2String(pszDrive) 26 cDir := Psz2String(pszDir) 27 cFile := Psz2String(pszFile) 28 cExt := Psz2String(pszExt) 29 MemFree(pszDrive) 30 MemFree(pszDir) 31 MemFree(pszFile) 32 MemFree(pszExt) 33 RETURN
1FUNCTION Start() 2 LOCAL cDrive, cDir, cFile, cExt AS STRING 3 MySplitPath("c:\develop\myprg\hello", ; 4 @cDrive, @cDir, @cFile, @cExt) 5 ? cDrive // C: 6 ? cDir // \DEVELOP\MYPRG 7 ? cFile // HELLO 8 ? SLen(cExt) // 0