8.3 Filename Format

How can I determine the 8.3 name of file from the long name? For that I need to communicate with the DOS-compatible FAT, right? How do I do that?
LVL 1
LeschaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nil_dibCommented:
long:  abcdefghi_1.xyz
8.3:   abcdef~1.xyz

nil_dib

0
ZoppoCommented:
which OS?

In Windows you can use GetShortPathName() API function.

ZOPPO
0
nietodCommented:
Zoppo, of course for for windows!  GetShortPathName() is the answer.  You should lock the question.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

ZoppoCommented:
Nietod, what if he wants to try to handle filenames created by i.e. Win95 on a FAT partition using a MS-DOS programm, i.e. if he can read the filenames 'LongFileName1.xxx' and 'LongFileName2.xxx' from a text file and needs to find out if 'LongFileName1.xxx' is 'LongFi~1.xxx' or 'LongFi~2.xxx' ???
0
nietodCommented:
I think that is far fetched....but possible, I suppose...Your points, your choice.
0
ZoppoCommented:
ok, ok, let's try ...

answer is (or might be): GetShortPathName()

ZOPPO

BTW, it's not a matter of course one is as fair as nietod telling me to lock the question instead of locking it himself. A really laudable, honorable trait :))
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nietodCommented:
I just want ti minimise any opportunity for a dispute to arrise.  Somone else could have come along and answer and then....
0
GastonCommented:
::FindFirstFile and ::FindNextFile return a WIN32_FILE_DATA struct, that contains in one of it's members the short name.
Go for it !
0
nietodCommented:
There doesn't seem to be any advantage to using FindFirstFile().  It should be less efficient (slower) Any you have more work to do as you have to close then find handle.
0
LeschaAuthor Commented:
Guys,

What I want to do is this:

when I use DIR command under DOS from Win95, I get the list that has both 8.3 names and long names. I want to get exactly the 8.3 names from that list.

However, if I use DIR command from 'Previous DOS mode' (6.22 in my case) I might get different 8.3 names. But this is irrelevant, because a program using any WinAPI function is not runnable under non-Win95 DOS, am I right?

In any case, the program is for Win95, so Zoppo's answer should work. I'll try it and grade the answer.

Thanks.
0
nietodCommented:
>>  if I use DIR command from 'Previous DOS mode'
>> (6.22 in my case) I might get different 8.3 names.
No.  The names will be the same.  Windows (x stores the 8.3 file name in the FAT system that DOS "understands" and then stores the long filename elsewhere, so DOS will see the same 8.3 name that windows uses.
0
LeschaAuthor Commented:
nietod,

well, it's a fact that I have a CD on which the directories, when under 6.22, show, for instance, DESIGN~1 (for "Designated"), while Win95 DOS shows me something like DESIGN~5, or smth like it.

And don't tell me it's a bug ;)

Have you heard the one about Microsoft selling times for commercials in their Windows Bug Reports?
0
nietodCommented:
I've never seen that happen with a any type of drive.  But it is a little more likely with a CD because a CD does not use FAT, so DOS does not have built-in features to read file infor from the CD.  This is handled by the CD driver.  However, I'm still a little surprised that this could happen.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.