Board index » delphi » DOS 8.3 filenames in Delphi 3

DOS 8.3 filenames in Delphi 3

 Is anybody aware of a function (or has anybody written a function) that
will convert Windows95/NT long file names to Dos 8.3 file names (i.e.
C:\Program Files\ = C:\PROGRA~1\).  I would really appreciate any insight
into how to do this.  Thank you very much.

Robert C. Ingebretsen

 

Re:DOS 8.3 filenames in Delphi 3


In article <5unqmm$eh...@news.aros.net>, r.c.ingebret...@m.cc.utah.edu says...

Quote

> Is anybody aware of a function (or has anybody written a function) that
>will convert Windows95/NT long file names to Dos 8.3 file names (i.e.
>C:\Program Files\ = C:\PROGRA~1\).  I would really appreciate any insight
>into how to do this.  Thank you very much.

>Robert C. Ingebretsen

  I don't quite understand your question, are you trying to take an
existing long name and get the DOS one?  If so, just use GetShortPathName.
But if you want to generate a DOS name from a list of long file names,
that is a different story.

   I ran into that problem a few months ago when I was using Delphi
but had to generate DOS names. Then I realized that I was asking the wrong
question: there can't be a function that correctly converts long names to
dos names unless its in reference to a disk; e.g. you can can have
c:\program files\ and
c:\program files old\

on the same disk drive, so without reference to a disk, the function
cannot be written.

  My solution was to create a temp directory, write long file names
there, then use GetShortPathname to retrieve the dos path name.  Since
this was a one time shot, I didn't care about making it general

-John_Mer...@Brown.EDU

Re:DOS 8.3 filenames in Delphi 3


On Thu, 4 Sep 1997 20:28:08 -0600, "Robert C. Ingebretsen"

Quote
<r.c.ingebret...@m.cc.utah.edu> wrote:
> Is anybody aware of a function (or has anybody written a function) that
>will convert Windows95/NT long file names to Dos 8.3 file names (i.e.
>C:\Program Files\ = C:\PROGRA~1\).  I would really appreciate any insight
>into how to do this.  Thank you very much.

Have a look at the GetShortPathName() API call in the Win32 Help file,
it does what you want.

HTH

Stephen Posey
slpo...@concentric.net

Re:DOS 8.3 filenames in Delphi 3


In article <3410af65.40266...@news.concentric.net>, Stephen Posey
<slpo...@concentric.net> writes

Quote
>Have a look at the GetShortPathName() API call in the Win32 Help file,
>it does what you want.

Is there a reverse for this function - i.e. to convert a filespec like
'c:\progra~1\direct~1\longfi~1.ext' to
'c:\program files\directory\longfilename.ext'?

Would it also work for a driectory, as in 'c:\progra~1\direct~1' to
'c:\program files\directory'?

If so, can it [and GetShortPathName] be called from a 16-bit app
(written in D1)?
My program will have found the 8.3 limited file-spec using the file-
system controls.

--
David James Spillett              Hiroshima '45, Chernobyl '86...
Admin....@bigfoot.com                                   Windows '95?
http://www.djspillett.demon.co.uk: home of WholeSite v1.2,
the one-click web-site updater. Oh, and some strange humour...

Re:DOS 8.3 filenames in Delphi 3


On Thu, 4 Sep 1997 20:28:08 -0600, "Robert C. Ingebretsen"

Quote
<r.c.ingebret...@m.cc.utah.edu> wrote:

> Is anybody aware of a function (or has anybody written a function) that
>will convert Windows95/NT long file names to Dos 8.3 file names (i.e.
>C:\Program Files\ = C:\PROGRA~1\).  I would really appreciate any insight
>into how to do this.  Thank you very much.

>Robert C. Ingebretsen

Robert,
Whilst I have not done this myself, I have written a couple of
functions for string amnipulation (ala Clipper) which might help.
Basically, what you want to do, is grab the piece of the string after
the last back slash, find the piece of this sub-string before the file
extension (if there is one; I would find it by looking for a period),
truncating the sub-string to 6 characters length, adding a tilde(~)
followed by 1, then concatenate this new string with the file
extension (if there is one). I would look for tjhis new file name, as
it is conceivable that it might exist. If it does, I would increment
the number at the end of the file name by one and test for the new
filename until you do not find it. Should work...

Re:DOS 8.3 filenames in Delphi 3


On Wed, 10 Sep 1997 20:39:45 GMT, nor...@acenet.co.za (Norman

Quote
McFarlane) wrote:

>On Thu, 4 Sep 1997 20:28:08 -0600, "Robert C. Ingebretsen"
><r.c.ingebret...@m.cc.utah.edu> wrote:

>> Is anybody aware of a function (or has anybody written a function) that
>>will convert Windows95/NT long file names to Dos 8.3 file names (i.e.
>>C:\Program Files\ = C:\PROGRA~1\).  I would really appreciate any insight
>>into how to do this.  Thank you very much.

>>Robert C. Ingebretsen
>Robert,
>Whilst I have not done this myself, I have written a couple of
>functions for string amnipulation (ala Clipper) which might help.
>Basically, what you want to do, is grab the piece of the string after
>the last back slash, find the piece of this sub-string before the file
>extension (if there is one; I would find it by looking for a period),
>truncating the sub-string to 6 characters length, adding a tilde(~)
>followed by 1, then concatenate this new string with the file
>extension (if there is one). I would look for tjhis new file name, as
>it is conceivable that it might exist. If it does, I would increment
>the number at the end of the file name by one and test for the new
>filename until you do not find it. Should work...

Why go through this instead of using the GetShortPathName Windows API
call?

For converting to 8.3 in Delphi 1, you need to jump through hoops and
thunk to 32 bits, but here, just use what's available.

David Block
dbl...@vdn.com

Re:DOS 8.3 filenames in Delphi 3


In article <3417238b.31033...@news.nothingbutnet.net>, David Block
<dbl...@vdn.com> writes

Quote
>Why go through this instead of using the GetShortPathName Windows API
>call?

>For converting to 8.3 in Delphi 1, you need to jump through hoops and
>thunk to 32 bits, but here, just use what's available.

Do you have any examples of this?

--
David James Spillett              Hiroshima '45, Chernobyl '86...
Admin....@bigfoot.com                                   Windows '95?
http://www.djspillett.demon.co.uk: home of WholeSite v1.2,
the one-click web-site updater. Oh, and some strange humour...

Re:DOS 8.3 filenames in Delphi 3


On Thu, 11 Sep 1997 21:40:02 +0100, David James Spillett

Quote
<Ad...@djspillett.demon.co.uk> wrote:
>In article <3417238b.31033...@news.nothingbutnet.net>, David Block
><dbl...@vdn.com> writes
>>Why go through this instead of using the GetShortPathName Windows API
>>call?

>>For converting to 8.3 in Delphi 1, you need to jump through hoops and
>>thunk to 32 bits, but here, just use what's available.
>Do you have any examples of this?

>--
>David James Spillett              Hiroshima '45, Chernobyl '86...
>Admin....@bigfoot.com                                   Windows '95?
>http://www.djspillett.demon.co.uk: home of WholeSite v1.2,
>the one-click web-site updater. Oh, and some strange humour...

RTFM! It's in the Windows API manuals, the Delphi help (type
"GetShortPathName', and press F1. You'll get:

The GetShortPathName function obtains the short path form of a
specified input path.

DWORD GetShortPathName(

    LPCTSTR  lpszLongPath,      // points to a null-terminated path
string
    LPTSTR   lpszShortPath,     // points to a buffer to receive the
null-terminated short form of the path
    DWORD  cchBuffer    // specifies the size of the buffer pointed to
by lpszShortPath
   );  
Parameters

lpszLongPath

Points to a null-terminated path string. The function obtains the
short form of this path.

lpszShortPath

Points to a buffer to receive the null-terminated short form of the
path specified by lpszLongPath.

cchBuffer

Specifies the size, in characters, of the buffer pointed to by
lpszShortPath.

David Block
dbl...@vdn.com

Re:DOS 8.3 filenames in Delphi 3


In article <34187e8c.33521...@news.nothingbutnet.net>, David Block
<dbl...@vdn.com> writes

Quote
>RTFM! It's in the Windows API manuals, the Delphi help (type
>"GetShortPathName', and press F1. You'll get:

Only if you have the 32bit API reference, which doesn't come with D1
(which I'm using). I assume you are using D2 or D3?

(BTW, thank to Duncan Murdoch - I'll try that when next I get my hands
on a Win95 installation to test it on)

--
David James Spillett              Hiroshima '45, Chernobyl '86...
Admin....@bigfoot.com                                   Windows '95?
http://www.djspillett.demon.co.uk: home of WholeSite v1.2,
the one-click web-site updater. Oh, and some strange humour...

Other Threads