Solved

Files whose extensions are hidden by Windows

Posted on 2002-05-21
14
327 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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