Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I get short path name in VFP?
Message
De
16/10/2002 16:14:17
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00711861
Message ID:
00711962
Vues:
18
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform