Board index » delphi » How do you get the DOS file name of a file with a long file name

How do you get the DOS file name of a file with a long file name

I am trying to programmatically change the current screen saver in
Windows95 using Delphi 2.0.  The only way I can see to do this is to
change the SCRNSAVE.EXE option in the SYSTEM.INI.

The problem is that when I write a file name to the ini file, it is in
the long file name format.  When Win95 goes to read the screen saver,
it comes up blank because (apparently) it is looking for a short file
name.

(I could write a function to convert a file name, but how a short file
name appears can be customized by editing the registry.  I would
prefer a solution robust enough to handle this possibility.)

Any ideas on determining the short file name of a file or even an
easier way to change the current screen saver?

Thanks in advance,

 - Mitchell S. Honnert

 

Re:How do you get the DOS file name of a file with a long file name


Check the FindFirstFile() Win32 API function...according to MS, it
converts between long and short file names...

Haven't tried it yet myself - just something I ran across...

HTH

Ken White
qpwpla...@aol.com

Re:How do you get the DOS file name of a file with a long file name


Quote
QPWPlatts <qpwpla...@aol.com> wrote:

: Check the FindFirstFile() Win32 API function...according to MS, it
: converts between long and short file names...

: Haven't tried it yet myself - just something I ran across...

: HTH

: Ken White
: qpwpla...@aol.com

Excellent tidbit !!  Here's a snippit I used to test it.

procedure TForm1.Button1Click(Sender: TObject);
var
   F      : TSearchRec;
   Fname  : String;

begin
  OpenDialog1.FileName := '*.*';
  If OpenDialog1.Execute then begin
      Fname := OpenDialog1.FileName;
      If FindFirst(Fname,faAnyFile,F) =0 then begin
         LongNlbl.Caption := F.FindData.cFileName;
         ShortNlbl.Caption := F.FindData.cAlternateFileName;
      end;
   end;
end;

---------------------------------------------------------------------
Gerry Kaslowski
Fountain Valley, CA
g...@primenet.com

Other Threads