Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: odd results using Borland's FindFirst function

25 May 2011   #1

Win 7 Home Premium 64bit
odd results using Borland's FindFirst function

After using Windows 7 for several months, suddenly getting odd file attribute values using FindFirst|FindNext VCL functions using Borland C++ Builder6 Enterprise.
The following code worked fine (for years in several versions of Windows)

TSearchRec sr;
int iAttributes = faDirectory;
if (FindFirst("*.*", iAttributes, sr) == 0)
if((sr.Name!=".") && (sr.Name!= ".."))
while (FindNext(sr) == 0)
if((sr.Name!=".") && (sr.Name!= ".."))

This writes all directories within a selected directory to a listbox.
Only it doesnt do this all of a sudden.
TSearchRec.Attr has begun to return a value of 0x2010 regardless of whether the file pointed to is a directory or a hidden|system|Any file!

Which means my listbox is filled with every file|directory in the specified dir, and not just the intended directories.
Can anybody make sense out of this? Is this a virus? Or is it a Windows 7 "feature" that packs more values into a file attribute?

My System SpecsSystem Spec

27 May 2011   #2

Win 7 Home Premium 64bit

since my post found a solution:
test TSearchRec.Attr with wanted attribute by and-ing them

if((sr.Attr & faDirectory) != 0)

Like the Borland Help documentation says ...

"To test for an attribute, combine the value of the Attr field with the attribute constant with the and operator. If the file has that attribute, the result will be greater than 0. For example, if the found file is a hidden file, the following expression will evaluate to true: (SearchRec.Attr & faHidden) != 0."

It helps to read the manual sometimes! (But still cant figure why my abbreviated version worked for so many years - until it ran into Windows 7 - maybe to do with 64bit integers?)

You can all sleep peacefully now...
My System SpecsSystem Spec

 odd results using Borland's FindFirst function

Thread Tools

Similar help and support threads for2: odd results using Borland's FindFirst function
Thread Forum
Help with Borland x64 Software
borland 5.02 help Software
Solved search function in explorer yields no results?! Software
borland c++ help Software
exe made with borland c++ builder 6.0 General Discussion
Function keys produce unexpected results--how to reset? Performance & Maintenance
Borland Delphi 7 Software

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 09:32 PM.
Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33