Article View: borland.public.cppbuilder.nativeapi
Article #224Determining an files true type
From: Mike Collins
Date: Tue, 15 Jul 2008 00:04
Date: Tue, 15 Jul 2008 00:04
35 lines
2695 bytes
2695 bytes
Hi all,
Got a bit of a conceptual question here. I have a piece of code that
performs a recursive search of the users hard disk and generates a list of
files. Nothing new here. My code is based around the FindFirstFile /
FindNextFile API's. From what I can see, there doesn't seem to be a way to
specify a wildcard search mask i.e. *.exe so it seems necessary to check for
.exe extension within the search, which I do like this:
AnsiString sFile = (AnsiString)fdFindFileData.cFileName;
if (ExtractFileExt(sFile).AnsiCompareIC(".exe")== 0)
// add to my list
- using ExtractFileExt() to retrieve the file extension. This seemed to
work fine. When I run it on my development machine, I get 2982 files
returned. However, if I fire up a command prompt and do dir *.exe /s I get
3001 files returned, a difference of 19 files. I dumped both lists to text
files and compared them (which I had to do by hand because they weren't in
the same order and I couldn't be bothered to write something to do it :-) ).
In the dir *.exe dump, I have some file like this:
C:\WINDOWS\Installer\$PatchCache$\Managed\9040110900063D11C8EF10054038389C\11.0.5614\SCANOST.EXE_1033
when I examine the properties, they appear as executable files (although
they appear to be back-ups and are not executable). Based on this, I was
wondering what the best option is to truly determine a executable?
My first thoughts are to just ignore them as they are not executable
per-say, but i'm interested in how the dir commend determines there file
type. Simply looking for ".exe" in the file name would not work because it
is possible to have a text document with the name "textfile.exe.txt".
Any thoughts or suggestions
Mike
Technical Details
Message-ID:
<487bd893@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,179fe31b934cb3c9,start X-Google-Attributes: gid10cc67,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Mike Collins" <its@TheBottomOfThePost> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Determining an files true type Date: Tue, 15 Jul 2008 00:04:00 -0000 Lines: 37 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.3959 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 NNTP-Posting-Host: 84.13.222.121 Message-ID: <487bd893@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1216075923 84.13.222.121 (14 Jul 2008 15:52:03 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail X-Original-Bytes: 2534