Board index » delphi » Long FileName - Short Filename conversion

Long FileName - Short Filename conversion

Hi,

I'm using BPW 7.0 under Windows 3.1 but any reply in any language will
be appreciated.

In order to be used under Win95 and use some of its features, I would
like to be able to convert between Long Filenames (with and without
full path) (for display) to Short filenames (old 8.3 format to use on
I/O) and vice-versa.

I know I have to look at int 21h but I've never coded in asm and am
afraid of doing it on my own.

If anybody has some informations, thanks in advance.

David.

 

Re:Long FileName - Short Filename conversion


Quote
David Tetard (mcdst...@fs1.ch.umist.ac.uk) wrote:

: Hi,
:
: I'm using BPW 7.0 under Windows 3.1 but any reply in any language will
: be appreciated.
:
: In order to be used under Win95 and use some of its features, I would
: like to be able to convert between Long Filenames (with and without
: full path) (for display) to Short filenames (old 8.3 format to use on
: I/O) and vice-versa.
:
: I know I have to look at int 21h but I've never coded in asm and am
: afraid of doing it on my own.
:

Try my (free) TPWIN32 package. Do a net search for tpw32_10.zip. It contains
BP/Delphi sources for thunking from 16 -> 32 bits.

Best regards, The Chief
--------
Dr. A{*word*73}la A. Olowofoyeku (The African Chief)
Email: la...@keele.ac.uk
Author of: Chief's Installer Pro 3.60 for Win16 and Win32:
           Winner of PC PLUS Magazine Gold Award (April 1995 U.K. edition)
           http://ourworld.compuserve.com/homepages/African_Chief/
           ftp://ftp.simtel.net/pub/simtelnet/win3/install/chief360.zip  

Re:Long FileName - Short Filename conversion


Quote
David Tetard wrote:

> Hi,

> I'm using BPW 7.0 under Windows 3.1 but any reply in any language will
> be appreciated.

> In order to be used under Win95 and use some of its features, I would
> like to be able to convert between Long Filenames (with and without
> full path) (for display) to Short filenames (old 8.3 format to use on
> I/O) and vice-versa.

> I know I have to look at int 21h but I've never coded in asm and am
> afraid of doing it on my own.

Why should you be afraid, especially if you already know the answer???
It doesn't hurt to try, does it? You computer is not going to explode
if you make a mistake. The worst that can happen is that it locks up,
and you'll have to press the reset button (ooh that's so scary !! :-))

Quote
> If anybody has some informations, thanks in advance.
> David.

Jesper de Jong
(jes...@xs4all.nl)

Re:Long FileName - Short Filename conversion


Il giorno Wed, 17 Sep 1997 08:37:25 +0000, David Tetard
<mcdst...@fs1.ch.umist.ac.uk> ha scritto :

Quote
>Hi,

>I'm using BPW 7.0 under Windows 3.1 but any reply in any language will
>be appreciated.

>In order to be used under Win95 and use some of its features, I would
>like to be able to convert between Long Filenames (with and without
>full path) (for display) to Short filenames (old 8.3 format to use on
>I/O) and vice-versa.

>I know I have to look at int 21h but I've never coded in asm and am
>afraid of doing it on my own.

>If anybody has some informations, thanks in advance.

>David.

Visit http://www.geocities.com/SiliconValley/Lakes/7668
and you will find a unit which handles LFN.

"Grattatio pallarum omnia mala fugit" (A.Laforgia)

Re:Long FileName - Short Filename conversion


Quote
David Tetard wrote:
> Hi,

> I'm using BPW 7.0 under Windows 3.1 but any reply in any language will

> be appreciated.

> In order to be used under Win95 and use some of its features, I would
> like to be able to convert between Long Filenames (with and without
> full path) (for display) to Short filenames (old 8.3 format to use on
> I/O) and vice-versa.

I had to solve this one once.  I didn't (and still don't) have access to
the underlying
operating system commands that messed with file names, but I was able to
spawn a
DOS command (that was built into my Pascal system).  I accordingly built
a command
of the form DIR whatever.ext > myanswer, i.e. I asked DOS 7 to give me a
directory
listing, putting the result in a file.  Note that DOS 7 gives listings
that have both the
8.3 and long file names on the same line.  It then was a simple matter
to parse the
directory listing, and I had the information I needed.  Plus, by
appropriate choice of
wild cards in my whatever.ext request, I could "filter" the listing
right up front.

Bob Schor
Pascal Enthusiast

Re:Long FileName - Short Filename conversion


This is a multi-part message in MIME format.

--------------6F43477B3A0D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Quote
David Tetard wrote:

> Hi,

> I'm using BPW 7.0 under Windows 3.1 but any reply in any language will
> be appreciated.

> In order to be used under Win95 and use some of its features, I would
> like to be able to convert between Long Filenames (with and without
> full path) (for display) to Short filenames (old 8.3 format to use on
> I/O) and vice-versa.

> I know I have to look at int 21h but I've never coded in asm and am
> afraid of doing it on my own.

> If anybody has some informations, thanks in advance.

> David.

Sorry about the Delay in answering, I had an example which I kept
forgetting to bring in. You use int 21h without ASM, pretty simple. Note
that I have cheated a bit, I only allow for a maximum filename of 255
characters, whereas you should allow for 260.

Mark

program longname ;
uses
 dos ;
var
 i       : integer ;
 longn   : string ;
 regs    : registers ;
 shortn  : string ;
begin ;
 { shortname to longname }
 shortn := 'c:\windows\shelli~1'#0 ;
 regs.ax := $7160 ;
 regs.cx := 2 ;
 regs.si := ofs(shortn)+1 ;
 regs.ds := seg(shortn) ;
 regs.di := ofs(longn)+1 ;
 regs.es := seg(longn) ;
 msdos(regs) ;
 if regs.flags and fcarry <> 0
 then begin ;
      writeln('Error ',regs.ax) ;
      halt ;
      end ;
 i := 1 ;
 while longn[i] <> #0 do inc(i) ;
 longn[0] := chr(pred(i)) ;
 writeln(longn) ;

 { Longname to shortname }
 longn := 'c:\windows\Gold Weave.bmp'#0 ;
 regs.ax := $7160 ;
 regs.cx := 1 ;
 regs.si := ofs(longn)+1 ;
 regs.ds := seg(longn) ;
 regs.di := ofs(shortn)+1 ;
 regs.es := seg(shortn) ;
 msdos(regs) ;
 if regs.flags and fcarry <> 0
 then begin ;
      writeln('Error ',regs.ax) ;
      halt ;
      end ;
 i := 1 ;
 while shortn[i] <> #0 do inc(i) ;
 shortn[0] := chr(pred(i)) ;
 writeln(shortn) ;
end .

--------------6F43477B3A0D
Content-Type: text/plain; charset=us-ascii; name="Longnam.pas"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Longnam.pas"

program longname ;
uses
 dos ;
var
 i       : integer ;
 longn   : string ;
 regs    : registers ;
 shortn  : string ;
begin ;
 { shortname to longname }
 shortn := 'c:\windows\shelli~1'#0 ;
 regs.ax := $7160 ;
 regs.cx := 2 ;
 regs.si := ofs(shortn)+1 ;
 regs.ds := seg(shortn) ;
 regs.di := ofs(longn)+1 ;
 regs.es := seg(longn) ;
 msdos(regs) ;
 if regs.flags and fcarry <> 0
 then begin ;
      writeln('Error ',regs.ax) ;
      halt ;
      end ;
 i := 1 ;
 while longn[i] <> #0 do inc(i) ;
 longn[0] := chr(pred(i)) ;
 writeln(longn) ;

 { Longname to shortname }
 longn := 'c:\windows\Gold Weave.bmp'#0 ;
 regs.ax := $7160 ;
 regs.cx := 1 ;
 regs.si := ofs(longn)+1 ;
 regs.ds := seg(longn) ;
 regs.di := ofs(shortn)+1 ;
 regs.es := seg(shortn) ;
 msdos(regs) ;
 if regs.flags and fcarry <> 0
 then begin ;
      writeln('Error ',regs.ax) ;
      halt ;
      end ;
 i := 1 ;
 while shortn[i] <> #0 do inc(i) ;
 shortn[0] := chr(pred(i)) ;
 writeln(shortn) ;
end .

--------------6F43477B3A0D--

Other Threads