Getting the long filename

How do I get the long filename for a given short ? (c:\progr~1 -> c:\Program Files).
The Explorer's "Send to"-Menu gives only the short name for a selected file/directory. How do I convert it.
Maybe you use SHGetLongFileName or GetLongFileName.
Please send me an example !

Thank you !
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Hi webers,

The examples are not from me, but I think this is what you need.

From: "DynaSoft." <>

Function GetShortFileName(Const FileName : String) : String;
  aTmp: array[0..255] of char;
  if GetShortPathName(PChar(FileName),aTmp,Sizeof(aTmp)-1)=0 then
     Result:= FileName

Function GetLongFileName(Const FileName : String) : String;
  aInfo: TSHFileInfo;
  if SHGetFileInfo(PChar(FileName),0,aInfo,Sizeof(aInfo),SHGFI_DISPLAYNAME)<>0 then
     Result:= String(aInfo.szDisplayName)
     Result:= FileName;

Have fun,
c.u. ZifNab;

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
webersAuthor Commented:
I haven't tested yte, but I think it'll work.
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

From novice to tech pro — start learning today.