Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Long File name support in Foxprow 2.6a

Program Source Code

Long File name support in Foxprow 2.6a

by  snix2  Posted    (Edited  )
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.
*************************************

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top