Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Files whose extensions are hidden by Windows

Posted on 2002-05-21
14
Medium Priority
?
334 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
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 200 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

782 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