Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WINMM.DLL and Saving File Names
Message
From
05/09/2001 11:18:21
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00552081
Message ID:
00552548
Views:
16
>No luck on this either. I just can't seem to make it work. Here is a more simple approach to the application that didn't work either.
>
>DECLARE INTEGER GetShortPathName IN Win32API STRING, STRING, INTEGER
>
>lcLongFile = "c:\program files\somefolder\my file name.doc"
>lcBuffer = SPACE(511)
>lnBufferSize = 511
>lnShortPathLen = GetShortPathName(lcLongFile, @lcBuffer, lnBufferSize)
>
>lcShortPath = LEFT(lcBuffer, lnBufferSize)
>
>MessageBox(lcShortPath,16,[Test])
>
>return

Here's the same thing with a slight modification, but messagebox() showed it right even without it:
DECLARE INTEGER GetShortPathName IN Win32API STRING, STRING, INTEGER

lcLongFile = "\\ZMYCHECK\CD ZMYCHECK\SMALL FACES & ROD STEWART\FACES & ROD STEWART - MEMPHIS, TENNESEE.MP3"
lcBuffer = SPACE(511)
lnBufferSize = 511
lnShortPathLen = GetShortPathName(lcLongFile, @lcBuffer, @lnBufferSize)

lcShortPath =Left(lcBuffer,at(chr(0), lcBuffer)-1)

MessageBox(lcShortPath,16,[Test])

* gives \\ZMYCHECK\CD ZMYCHECK\SMALLF~9\FACES&~9.MP3
Couple of notes:
- I thought the lnBufferSize must be passed by reference, so its value would reflect the change in size, i.e. would hold the length of the result. On the contrary, it remains unchanged. I tried this as an analogy to GetPrivateProfileString, where it does carry the length.
- MessageBox, being not a Fox command (it's actually a wrapper around a system call), behaves differently - it stops at the first binary zero, which is a string delimiter in C. In VFP, you still see 511 bytes in lcShortPath, and that's why I changed the line lcShortPath=.
- Note that in my case it has kept the space in the share name - as far as the OS is concerned, "\\ZMYCHECK\CD ZMYCHECK\" is the drive name, though JustDrive(lcShortPath) would give you nothing, but that's because JustDrive looks for a colon - it's somewhat obsolete and doesn't understand UNCs.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform