Solved

Files whose extensions are hidden by Windows

Posted on 2002-05-21
14
325 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
14 Comments
 
LVL 6

Expert Comment

by:Stuart_Johnson
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 6

Expert Comment

by:Stuart_Johnson
Comment Utility
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
Comment Utility
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
Comment Utility
Oh!  Another fellow Aussie!  Where are you?  I'm in Hornsby.

Stu
0
 

Author Comment

by:nigeltodd
Comment Utility
melbourne - the dandenongs
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
Comment Utility
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
Comment Utility
melbourne - the dandenongs
0
 
LVL 1

Expert Comment

by:pnh73
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now