Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I get short path name in VFP?
Message
 
To
16/10/2002 13:57:01
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00711861
Message ID:
00815193
Views:
11
>>Hi, Everyone,
>>
>>Please help. I am using an Image Printer which only takes short file path and name, so I must convert the long file name that I use in VFP. So I found GetShortPathName in WIN32API. But I get very unpredictable results: sometimes the function succeds while other times fail with the exactly the same parameters that I pass to the function.
>
>From Erik Moore's API article on the function (Windows API ID: 12642):
>
>DECLARE INTEGER GetShortPathName IN Win32API ;
>   STRING  @cLongPath, ;
>   STRING  @cShortPathBuff, ;
>   INTEGER nBuffSize
>
>lcLongFile = "c:\program files\somefolder\my file name.doc"
>lcBuffer = SPACE(511)
>lnBufferSize = 511
>lnShortPathLen = GetShortPathName(lcLongFile, @lcBuffer, @lnBufferSize)
>
>lcShortPath = LEFT(lcBuffer, lnBufferSize)
>
>
I realize this is an old thread, but for the record, please note that the last line of Eric's example should read:
lcShortPath = LEFT(lcBuffer, lnShortPathLen)
Update: also I believe the last argument to GetShortPathName should not be passed by reference, and the declaration of the first argument doesn't seem to call for an "@", because this is a constant string (input). Only the second string argument is an output value. (I'm not sure if the use of @ on a string argument is really significant, except as a convention.)

Mike
Montage

"Free at last..."
Previous
Reply
Map
View

Click here to load this message in the networking platform