Here's a quick snippet which converts long file name paths to foxpro compatible short file paths. e.g. 'c:\program files' becomes 'c:\progra~1'.
*************************************************
* This function will convert long path names to
* foxpro compatible short path names
* It uses the winapi function 'GetShortPathName'
* And the foxpro FOXTOOLS.FLL library
*************************************************
set library to sys(2004)+'FOXTOOLS.FLL'
*** Register the windows API function...
GetShort = regfn('GetShortPathName','@C@CI','I')
*** Create a variable for holding the results
Buffer = SPACE(500)
*** Set the longpath variable to be the normal long pathname
*** Example here is c:\program files...
longpath = ALLTRIM(SYS(5)) + '\Program Files'
*** Call the function
Result = callfn(GetShort, @longpath, @buffer, 500)
*** remove the trailing null terminating character (Chr(0))
Buffer = left(buffer, result)
? Buffer
*************************************
** Now the 'buffer' variable contains an
** untrimmed short path name
** The 'Result' variable holds a number.
** This number is the number of characters long
** that the short file name is.
** Usable by foxpro.
*************************************
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.