Solved

Files whose extensions are hidden by Windows

Posted on 2002-05-21
14
329 Views
Last Modified: 2010-04-04
I hav an app which uses filexists function to find and open .txt & .dic files if they are found.

If Windows has the registry set to HideFileExt, the files cannot be found, and hence not opened.  I can patch the registry to correct this, but I'd rather not do it this way.

Any thoughts on how to make Delphi find files whose extensions are hidden?

Am using D5 Enterprise - first version.

0
Comment
Question by:nigeltodd
[X]
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
14 Comments
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 7026225
Nigel,

Strangely enough it works for me regardless of the setting.  I'm using D5 Ent as well on Windows XP Home.

Try:

var
  SR: TSearchRec;
begin
  if FindFirst(Filename, faANyFile, SR) = 0 then
    Label1.Caption := 'Found'
  else
    Label1.Caption := 'Not Found';
  FindClose(SR);

See if that works for you.

Stu
0
 
LVL 17

Expert Comment

by:geobul
ID: 7026290
Hi,

procedure TForm1.Button1Click(Sender: TObject);
begin
  if FileExists('c:\test1.doc') then ShowMessage('Exists!')
  else ShowMessage('Not Found!');
end;

also works fine with both settings. D5 Ent and XP|2000.

Regards, Geo
0
 

Author Comment

by:nigeltodd
ID: 7026602
Fileexists seems to only work when I have set Windows to NOT HideFileExt in the registry. It seems that something in Delphi or Windows has a problem finding a file in this situation.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 50 total points
ID: 7026755
Nigel,

This HideFileExt you're talking about.  Is this set through Explorer, Tools, Folder Options, View, Hide File Extensions for known file types?  If not, where abouts is it?

Did you try the FindFirst sample I offered?  Perhaps that will work for you.

Stu
0
 

Author Comment

by:nigeltodd
ID: 7028544
Stu,

Have not yet tried using findfirst. The HideFileExt is set by the method you describe. I can also set it in the registry, but I then have the problem of rereading the registry by rebooting or other questionable means!

Will try findfirst tonight and see what happens.

Nigel
0
 

Author Comment

by:nigeltodd
ID: 7028648
Stu,

Have just tried it on another machine, and it works fine with or withouit HideFileExt enabled, using findfirst or fileexists.

Same code, same O/S - will still try it at home tonight.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 7028670
That's a really weird problem.  I've never heard of that happening before.  AFAIK, that setting is just a masking property for the explorer window, not for the actual operating system.

Stu
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 7028671
That's a really weird problem.  I've never heard of that happening before.  AFAIK, that setting is just a masking property for the explorer window, not for the actual operating system.

Stu
0
 

Author Comment

by:nigeltodd
ID: 7028675
Will have to wait & see what happens at home tonight. As it is now 12:00pm, here in Australia, it will be 3 - 4 in the morning your time by the time I get to do it.

Talk to you soon.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 7028676
Oh!  Another fellow Aussie!  Where are you?  I'm in Hornsby.

Stu
0
 

Author Comment

by:nigeltodd
ID: 7028749
melbourne - the dandenongs
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 7028760
Beautiful spot.  I used to live in Glen Waverly before it became suburbius maximus (about 12 years ago) and used to love going up there on the weekends.

Stu
0
 

Author Comment

by:nigeltodd
ID: 7028778
melbourne - the dandenongs
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9006602
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from Stuart Johnson

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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