Board index » delphi » Q: Long and Short filenames?

Q: Long and Short filenames?

How do I convert from short to long filenames and long to short filenames?

If I Drag and Drop to a D3 application icon to launch, it passes short
filenames. I wish to show them as a longfilenames.  If I drag and Drop to a
running D3 application it passes long filenames.

Howard

--------------------- "Any personal opinions are!" -------------------
Howard J. Harvey                  |  hhar...@dove.net.au
Houghton, 5131, South Australia   |  http://dove.mtx.net.au/~hharvey
---------- c = 1802617499785.254116 furlongs/fortnight ---------------

 

Re:Q: Long and Short filenames?


On Sun, 05 Apr 1998 02:33:39 GMT, hhar...@dove.net.au (Howard Harvey)
wrote:

Quote
>How do I convert from short to long filenames and long to short filenames?

>If I Drag and Drop to a D3 application icon to launch, it passes short
>filenames. I wish to show them as a longfilenames.  If I drag and Drop to a
>running D3 application it passes long filenames.

Use FindFirst to get a record that contains both, and pick out
whichever one you need.

Duncan Murdoch

Re:Q: Long and Short filenames?


Quote
>How do I convert from short to long filenames and long to short filenames?

This code from RxLib:

function ShortToLongFileName(const ShortName: string): string;
var
  Temp: TWIN32FindData;
  SearchHandle: THandle;
begin
  SearchHandle := FindFirstFile(PChar(ShortName), Temp);
  if SearchHandle <> ERROR_INVALID_HANDLE then begin
    Result := string(Temp.cFileName);
    if Result = '' then Result := string(Temp.cAlternateFileName);
  end
  else Result := '';
  Windows.FindClose(SearchHandle);
end;

function ShortToLongPath(const ShortName: string): string;
var
  LastSlash: PChar;
  TempPathPtr: PChar;
begin
  Result := '';
  TempPathPtr := PChar(ShortName);
  LastSlash := StrRScan(TempPathPtr, '\');
  while LastSlash <> nil do begin
    Result := '\' + ShortToLongFileName(TempPathPtr) + Result;
    if LastSlash <> nil then begin
      LastSlash^ := char(0);
      LastSlash := StrRScan(TempPathPtr, '\');
    end;
  end;
  Result := TempPathPtr + Result;
end;

Best wishes,
Andrew Anoshkin
v...@dataforce.net
Useful programs and components:
http://www.strongsoftware.net/dronix/eng.html

Quote

>If I Drag and Drop to a D3 application icon to launch, it passes short
>filenames. I wish to show them as a longfilenames.  If I drag and Drop to a
>running D3 application it passes long filenames.

>Howard

>--------------------- "Any personal opinions are!" -------------------
>Howard J. Harvey                  |  hhar...@dove.net.au
>Houghton, 5131, South Australia   |  http://dove.mtx.net.au/~hharvey
>---------- c = 1802617499785.254116 furlongs/fortnight ---------------

Other Threads