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 22:11:13
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:
00712150
Vues:
12
>The technique you have given to me which is:
>does not work, which I hate to admit.

I'll try again.

Let's say you decide a file will be called "My Tiff File.TIF"
Let's say you wan to store it in the program directory.
Let's say that directory is "c:\program files\My bothersome App\".

Then, the idea is:
1. Createa file with the name you want your TIF to be called.
2. Get the shortname of that, 0-byte file, which now exists.
3. Pass the name of the file to your printer driver.

If your printer driver will not overwrite the 0-byte temporary file with the real file, then, delete it first. Like so.
DECLARE INTEGER GetShortPathName IN Win32API ;
   STRING  @cLongPath, ;
   STRING  @cShortPathBuff, ;
   INTEGER nBuffSize

lcLongFile = FULLPATH(CURDIR()) + "My Tiff File.TIF"
*!* Note that the directory exists, the TIF does not.

lnFH = FCREATE(lcLongFile )
IF lnFH # -1 && Make sure the file was created.
  FCLOSE(lnFH) && Close it so the printer driver can write over it.
ENDIF

lcBuffer = SPACE(511)
lnBufferSize = 511
lnShortPathLen = GetShortPathName(lcLongFile, @lcBuffer, @lnBufferSize)
lcShortPath = LEFT(lcBuffer, lnBufferSize)

?lcShortPath

*!* Pass the lcShortPath, or JUSTFNAME(lcShortPath) to the printer driver routine.
*!* You <b>may</b> have to delete the temporary file first, but you'll still have a valid 8+3 character file name.
Or just create an 8 character long file name to begin with.

Now, since we've all exchanged several messages where we're all saying exactly the same thing over and over, if any of this post isn't clear, it would be helpful if you say exactly what doesn't work and, even more importantly, why. Please be specific and use this example.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform