>Hi,Nancy,
>
>The method you have proposed didn't work. I tried different things such as changing the buffer size, declare the function with an alias, passing the parameters both by values and/or reference.
It helps to know all the relevent details. For example, I see in your reply to George that you need to convert a long filename to a shortfile name before the file exists on disk. So, from that I am assuming that when you say it "didn't work" you mean that it returns an empty string and that the path you're passing doesn't exist.
>I don't know why?
The API documentation for GetShortPathName doesn't say explicitly that the long filename has to exist, but that makes sense to me, since the shortname depends on that. Otherwise, it won't know if the file would need a ~1.
Will you be creating this file yourself? If so then perhaps you could do the following
DECLARE INTEGER GetShortPathName IN Win32API ;
STRING @cLongPath, ;
STRING @cShortPathBuff, ;
INTEGER nBuffSize
lcLongFile = "c:\temp\My Really Long FileName.TXT"
lnFH = FCREATE(lcLongFile )
IF lnFH # -1
FCLOSE(lnFH)
ENDIF
lcBuffer = SPACE(511)
lnBufferSize = 511
lnShortPathLen = GetShortPathName(lcLongFile, @lcBuffer, @lnBufferSize)
lcShortPath = LEFT(lcBuffer, lnBufferSize)
?lcShortPath