Solved

Files whose extensions are hidden by Windows

Posted on 2002-05-21
14
330 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
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!

 
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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

718 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