Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Getting the long filename

Posted on 1997-10-02
2
183 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IdTCPClient and IdTCPServer exchanging data on desktops and not Android 11 140
RESTRequest Parameter 4 41
DBCtrlGrid, Delphi, Scroll 7 24
Firemonkey BASS_Init into a thread 17 30
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

792 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