Solved

Getting the long filename

Posted on 1997-10-02
2
182 Views
Last Modified: 2010-04-04
How do I get the long filename for a given short ? (c:\progr~1 -> c:\Program Files).
E.g.:
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 !
0
Comment
Question by:webers
2 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 10 total points
ID: 1346754
Hi webers,

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

From: "DynaSoft." <TimH@onaustralia.com.au>

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

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

Have fun,
c.u. ZifNab;
0
 

Author Comment

by:webers
ID: 1346755
I haven't tested yte, but I think it'll work.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question